diff options
author | W. Felix Handte <w@felixhandte.com> | 2018-04-19 17:02:55 (GMT) |
---|---|---|
committer | W. Felix Handte <w@felixhandte.com> | 2018-04-20 00:54:35 (GMT) |
commit | 0abc23f72e44dd9af86e7fb61a2497cee81ed320 (patch) | |
tree | d8d7a5bcf2188da06ccf6120460ab3ecb682fc09 /lib | |
parent | b67de2a327644607c034250d105ba9374b0897e8 (diff) | |
download | lz4-0abc23f72e44dd9af86e7fb61a2497cee81ed320.zip lz4-0abc23f72e44dd9af86e7fb61a2497cee81ed320.tar.gz lz4-0abc23f72e44dd9af86e7fb61a2497cee81ed320.tar.bz2 |
Copy DictCtx into Working Context on Inputs Larger than 4 KB
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4hc.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c index c050c59..c201559 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 ( |