Preserve currentOffset==0 When Possible
authorW. Felix Handte <w@felixhandte.com>
Thu, 8 Mar 2018 19:09:06 +0000 (14:09 -0500)
committerW. Felix Handte <w@felixhandte.com>
Mon, 12 Mar 2018 18:59:28 +0000 (14:59 -0400)
lib/lz4.c

index 82c0ae3..1ea8ba1 100644 (file)
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -846,7 +846,9 @@ int LZ4_compress_fast_safeExtState(void* state, const char* source, char* dest,
         } else {
             const tableType_t tableType = (sizeof(void*)==8) ? byU32 : byPtr;
             LZ4_resetTable(ctx, inputSize, tableType, noDict);
-            ctx->currentOffset += 64 KB;
+            if (ctx->currentOffset) {
+              ctx->currentOffset += 64 KB;
+            }
             return LZ4_compress_generic(ctx, source, dest, inputSize, 0,    notLimited, tableType, noDict, noDictIssue, acceleration);
         }
     } else {
@@ -861,7 +863,9 @@ int LZ4_compress_fast_safeExtState(void* state, const char* source, char* dest,
         } else {
             const tableType_t tableType = (sizeof(void*)==8) ? byU32 : byPtr;
             LZ4_resetTable(ctx, inputSize, tableType, noDict);
-            ctx->currentOffset += 64 KB;
+            if (ctx->currentOffset) {
+              ctx->currentOffset += 64 KB;
+            }
             return LZ4_compress_generic(ctx, source, dest, inputSize, maxOutputSize, limitedOutput, tableType, noDict, noDictIssue, acceleration);
         }
     }