streaming compression example can handle situations where input buffer size is manually set to a small value.

dev
Yann Collet 2016-09-18 12:17:51 +02:00
parent 88aa179347
commit 4ca3d4bc25
1 changed files with 1 additions and 0 deletions

View File

@ -81,6 +81,7 @@ static void compressFile_orDie(const char* fname, const char* outName, int cLeve
while (input.pos < input.size) { while (input.pos < input.size) {
ZSTD_outBuffer output = { buffOut, buffOutSize, 0 }; ZSTD_outBuffer output = { buffOut, buffOutSize, 0 };
toRead = ZSTD_compressStream(cstream, &output , &input); /* toRead is guaranteed to be <= ZSTD_CStreamInSize() */ toRead = ZSTD_compressStream(cstream, &output , &input); /* toRead is guaranteed to be <= ZSTD_CStreamInSize() */
if (toRead > buffInSize) toRead = buffInSize; /* Safely handle when `buffInSize` is manually changed to a smaller value */
fwrite_orDie(buffOut, output.pos, fout); fwrite_orDie(buffOut, output.pos, fout);
} }
} }