]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fixed comments
authorYann Collet <cyan@fb.com>
Mon, 3 Jul 2017 22:52:19 +0000 (15:52 -0700)
committerYann Collet <cyan@fb.com>
Mon, 3 Jul 2017 22:52:19 +0000 (15:52 -0700)
lib/compress/zstd_compress.c
lib/compress/zstdmt_compress.c

index 2d57bc2d05e8fd422c5686c7af218047d34f25eb..c1e7cb5c5741d25a7a2b71c7e3989568296e6c7a 100644 (file)
@@ -3215,7 +3215,7 @@ static size_t ZSTD_compressBegin_internal(ZSTD_CCtx* cctx,
                                    ZSTD_buffered_policy_e zbuff)
 {
     DEBUGLOG(4, "ZSTD_compressBegin_internal");
-    DEBUGLOG(4, "dict ? %s", dict ? "dict" : cdict ? "cdict" : "none");
+    DEBUGLOG(4, "dict ? %s", dict ? "dict" : (cdict ? "cdict" : "none"));
     DEBUGLOG(4, "dictMode : %u", (U32)dictMode);
     /* params are supposed to be fully validated at this point */
     assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
@@ -3803,7 +3803,7 @@ size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
 
         case zcss_load:
             if ( (flushMode == ZSTD_e_end)
-              && ((size_t)(oend-op) >= ZSTD_compressBound(iend-ip))
+              && ((size_t)(oend-op) >= ZSTD_compressBound(iend-ip))  /* enough dstCapacity */
               && (zcs->inBuffPos == 0) ) {
                 /* shortcut to compression pass directly into output buffer */
                 size_t const cSize = ZSTD_compressEnd(zcs,
@@ -3815,8 +3815,8 @@ size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
                 zcs->frameEnded = 1;
                 ZSTD_startNewCompression(zcs);
                 someMoreWork = 0; break;
-              }
-            /* complete inBuffer */
+            }
+            /* complete loading into inBuffer */
             {   size_t const toLoad = zcs->inBuffTarget - zcs->inBuffPos;
                 size_t const loaded = ZSTD_limitCopy(
                                         zcs->inBuff + zcs->inBuffPos, toLoad,
index c203bf33744570f2f3ae1d5ffc4f1fd5ad332501..9e44da8b26879c3fb92d5c82fe04bc7cc5fda019 100644 (file)
@@ -527,8 +527,8 @@ size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx,
             dstBufferPos += dstBufferCapacity;
             remainingSrcSize -= chunkSize;
     }   }
-    /* note : since nbChunks <= nbThreads, all jobs should be running immediately in parallel */
 
+    /* collect result */
     {   unsigned chunkID;
         size_t error = 0, dstPos = 0;
         for (chunkID=0; chunkID<nbChunks; chunkID++) {
@@ -547,10 +547,10 @@ size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx,
             {   size_t const cSize = mtctx->jobs[chunkID].cSize;
                 if (ZSTD_isError(cSize)) error = cSize;
                 if ((!error) && (dstPos + cSize > dstCapacity)) error = ERROR(dstSize_tooSmall);
-                if (chunkID) {   /* note : chunk 0 is already written directly into dst */
+                if (chunkID) {   /* note : chunk 0 is written directly at dst, which is correct position */
                     if (!error)
-                        memmove((char*)dst + dstPos, mtctx->jobs[chunkID].dstBuff.start, cSize);  /* may overlap if chunk decompressed within dst */
-                    if (chunkID >= compressWithinDst) {  /* otherwise, it decompresses within dst */
+                        memmove((char*)dst + dstPos, mtctx->jobs[chunkID].dstBuff.start, cSize);  /* may overlap when chunk compressed within dst */
+                    if (chunkID >= compressWithinDst) {  /* chunk compressed into its own buffer, which must be released */
                         DEBUGLOG(5, "releasing buffer %u>=%u", chunkID, compressWithinDst);
                         ZSTDMT_releaseBuffer(mtctx->buffPool, mtctx->jobs[chunkID].dstBuff);
                     }