Skip to content

Commit

Permalink
[io] avoid unnecessary heap allocation in TFile::MakeFree
Browse files Browse the repository at this point in the history
  • Loading branch information
silverweed committed Jan 30, 2025
1 parent 356ba3e commit 390465c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions io/io/src/TFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1492,20 +1492,18 @@ void TFile::MakeFree(Long64_t first, Long64_t last)
Long64_t nbytesl= nlast-nfirst+1;
if (nbytesl > 2000000000) nbytesl = 2000000000;
Int_t nbytes = -Int_t (nbytesl);
Int_t nb = sizeof(Int_t);
char * buffer = new char[nb];
char * psave = buffer;
tobuf(buffer, nbytes);
char buffer[sizeof(Int_t)];
char *pbuffer = buffer;
tobuf(pbuffer, nbytes);
if (last == fEND-1) fEND = nfirst;
Seek(nfirst);
// We could not update the meta data for this block on the file.
// This is not fatal as this only means that we won't get it 'right'
// if we ever need to Recover the file before the block is actually
// (attempted to be reused.
// coverity[unchecked_value]
WriteBuffer(psave, nb);
WriteBuffer(buffer, sizeof(buffer));
if (fMustFlush) Flush();
delete [] psave;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 390465c

Please sign in to comment.