]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added error message, updated copying dictionary into the input buffer
authorPaul Cruz <paulcruz74@fb.com>
Tue, 11 Jul 2017 22:00:52 +0000 (15:00 -0700)
committerPaul Cruz <paulcruz74@fb.com>
Tue, 11 Jul 2017 22:00:52 +0000 (15:00 -0700)
contrib/adaptive-compression/adapt.c

index 9a527ff5e8a706c3c80de6c109fee19fbab9cb3f..2bd1c4f9586eeb1a0404749b8a9e2b2b4aa27d4c 100644 (file)
@@ -270,6 +270,7 @@ static void* compressionThread(void* arg)
             if (currJob != 0) { /* not first job */
                 size_t const hSize = ZSTD_compressContinue(ctx->cctx, job->dst.start, job->dst.size, job->src.start, job->src.size);
                 if (ZSTD_isError(hSize)) {
+                    DISPLAY("Error: something went wrong while continuing compression\n");
                     job->compressedSize = hSize;
                     ctx->threadError = 1;
                     return arg;
@@ -410,8 +411,10 @@ static int createCompressionJob(adaptCCtx* ctx, size_t srcSize, int last)
 
     /* if not on the last job, reuse data as dictionary in next job */
     if (!last) {
-        ctx->input.filled = srcSize;
-        memmove(ctx->input.buffer.start, ctx->input.buffer.start + ctx->input.filled, srcSize);
+        size_t const newDictSize = srcSize;
+        size_t const oldDictSize = ctx->input.filled;
+        memmove(ctx->input.buffer.start, ctx->input.buffer.start + oldDictSize + srcSize - newDictSize, newDictSize);
+        ctx->input.filled = newDictSize;
     }
     return 0;
 }