]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
zstdmt : fixed last job size
authorYann Collet <cyan@fb.com>
Sat, 20 Jan 2018 02:19:09 +0000 (18:19 -0800)
committerYann Collet <cyan@fb.com>
Sat, 20 Jan 2018 02:19:09 +0000 (18:19 -0800)
lib/compress/zstdmt_compress.c

index 3e665f574e391ef125bcf389f6f4bfbb806476ed..c204fb84baa04a62861de46c6806fce018d8ef2d 100644 (file)
@@ -1220,7 +1220,8 @@ size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
     if ( (mtctx->jobReady)
       || (mtctx->inBuff.filled >= newJobThreshold)  /* filled enough : let's compress */
       || ( (endOp != ZSTD_e_continue) && (mtctx->inBuff.filled > 0) ) ) {   /* avoid overwriting job round buffer */
-        CHECK_F( ZSTDMT_createCompressionJob(mtctx, mtctx->targetSectionSize, 0 /* endFrame */) );
+        size_t const jobSize = MIN(mtctx->inBuff.filled - mtctx->prefixSize, mtctx->targetSectionSize);
+        CHECK_F( ZSTDMT_createCompressionJob(mtctx, jobSize, endOp==ZSTD_e_end) );
     }
 
     /* check for potential compressed data ready to be flushed */