aboutsummaryrefslogtreecommitdiff
path: root/lib/lz4hc.c
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2018-04-19 13:02:55 -0400
committerW. Felix Handte <w@felixhandte.com>2018-04-19 20:54:35 -0400
commit0abc23f72e44dd9af86e7fb61a2497cee81ed320 (patch)
treed8d7a5bcf2188da06ccf6120460ab3ecb682fc09 /lib/lz4hc.c
parentb67de2a327644607c034250d105ba9374b0897e8 (diff)
downloadlz4-0abc23f72e44dd9af86e7fb61a2497cee81ed320.tar.gz
Copy DictCtx into Working Context on Inputs Larger than 4 KB
Diffstat (limited to 'lib/lz4hc.c')
-rw-r--r--lib/lz4hc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index c050c59b..c201559a 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -720,6 +720,8 @@ LZ4_FORCE_INLINE int LZ4HC_compress_generic_internal (
}
}
+static void LZ4HC_setExternalDict(LZ4HC_CCtx_internal* ctxPtr, const BYTE* newBlock);
+
static int LZ4HC_compress_generic_noDictCtx (
LZ4HC_CCtx_internal* const ctx,
const char* const src,
@@ -745,7 +747,16 @@ static int LZ4HC_compress_generic_dictCtx (
)
{
assert(ctx->dictCtx != NULL);
- return LZ4HC_compress_generic_internal(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit, usingDictCtx);
+ if (*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;
+ }
}
static int LZ4HC_compress_generic (