diff options
author | W. Felix Handte <w@felixhandte.com> | 2018-04-19 21:51:10 (GMT) |
---|---|---|
committer | W. Felix Handte <w@felixhandte.com> | 2018-04-20 00:54:35 (GMT) |
commit | f4b13e17ea110498c41ba3ac8dc6df0438c37d29 (patch) | |
tree | fcd69335ca09a69502b9f73a9920a33c08647b09 | |
parent | 0abc23f72e44dd9af86e7fb61a2497cee81ed320 (diff) | |
download | lz4-f4b13e17ea110498c41ba3ac8dc6df0438c37d29.zip lz4-f4b13e17ea110498c41ba3ac8dc6df0438c37d29.tar.gz lz4-f4b13e17ea110498c41ba3ac8dc6df0438c37d29.tar.bz2 |
Don't Clear the Dictionary Context Until No Longer Useful
-rw-r--r-- | lib/lz4hc.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c index c201559..9a02787 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -746,15 +746,18 @@ static int LZ4HC_compress_generic_dictCtx ( limitedOutput_directive limit ) { + size_t position = ctx->end - ctx->base - ctx->lowLimit; assert(ctx->dictCtx != NULL); - if (*srcSizePtr > 4 KB) { + if (position >= 64 KB) { + ctx->dictCtx = NULL; + return LZ4HC_compress_generic_noDictCtx(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit); + } else if (position == 0 && *srcSizePtr > 4 KB) { memcpy(ctx, ctx->dictCtx, sizeof(LZ4HC_CCtx_internal)); LZ4HC_setExternalDict(ctx, (const BYTE *)src); ctx->compressionLevel = cLevel; return LZ4HC_compress_generic_noDictCtx(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit); } else { int result = LZ4HC_compress_generic_internal(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit, usingDictCtx); - ctx->dictCtx = NULL; return result; } } |