]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Set dictionary ID in ZSTD_initCStream_usingCDict() 511/head
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 15 Jan 2017 01:44:54 +0000 (17:44 -0800)
committerGregory Szorc <gregory.szorc@gmail.com>
Sun, 15 Jan 2017 01:44:54 +0000 (17:44 -0800)
When porting python-zstandard to use ZSTD_initCStream_usingCDict()
so compression dictionaries could be reused, an automated test
failed due to compressed content changing.

I tracked this down to ZSTD_initCStream_usingCDict() not
setting the dictID field of the ZSTD_CCtx attached to the
ZSTD_CStream instance.

I'm not 100% convinced this is the correct or full solution,
as I'm still seeing one automated test failing with this change.

lib/compress/zstd_compress.c

index 7626b33a685672bc66d993ed790f4f6f31916e48..4408644c6405f6c04e824d58495d3f971c0aca2f 100644 (file)
@@ -2970,6 +2970,7 @@ size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict)
     ZSTD_parameters const params = ZSTD_getParamsFromCDict(cdict);
     size_t const initError =  ZSTD_initCStream_advanced(zcs, NULL, 0, params, 0);
     zcs->cdict = cdict;
+    zcs->cctx->dictID = params.fParams.noDictIDFlag ? 0 : cdict->refContext->dictID;
     return initError;
 }