File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -559,14 +559,17 @@ static char * Io_LibLoadFileGz( char * pFileName, long * pnFileSize )
559559 const int READ_BLOCK_SIZE = 100000 ;
560560 gzFile pFile ;
561561 char * pContents ;
562- long amtRead , readBlock , nFileSize = READ_BLOCK_SIZE ;
562+ long amtRead , readBlock , nFileSize = READ_BLOCK_SIZE , nCapacity = READ_BLOCK_SIZE ;
563563 pFile = gzopen ( pFileName , "rb" ); // if pFileName doesn't end in ".gz" then this acts as a passthrough to fopen
564- pContents = ABC_ALLOC ( char , nFileSize );
564+ pContents = ABC_ALLOC ( char , nCapacity );
565565 readBlock = 0 ;
566566 while ((amtRead = gzread (pFile , pContents + readBlock * READ_BLOCK_SIZE , READ_BLOCK_SIZE )) == READ_BLOCK_SIZE ) {
567567 //Abc_Print( 1,"%d: read %d bytes\n", readBlock, amtRead);
568568 nFileSize += READ_BLOCK_SIZE ;
569- pContents = ABC_REALLOC (char , pContents , nFileSize );
569+ if ( nFileSize > nCapacity ) {
570+ nCapacity *= 2 ;
571+ pContents = ABC_REALLOC (char , pContents , nCapacity );
572+ }
570573 ++ readBlock ;
571574 }
572575 //Abc_Print( 1,"%d: read %d bytes\n", readBlock, amtRead);
You can’t perform that action at this time.
0 commit comments