From e34716cc3f54d3fca1cbd797e8af003cd3a63bc8 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Thu, 8 Mar 2018 14:09:06 -0500 Subject: [PATCH] Preserve currentOffset==0 When Possible --- lib/lz4.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/lz4.c b/lib/lz4.c index 82c0ae3..1ea8ba1 100644 --- 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); } } -- 2.7.4