Fix parameter retrieval from cdict

This commit is contained in:
Stella Lau 2017-08-25 17:58:28 -07:00
parent 2adde898c8
commit 024098a47d
3 changed files with 11 additions and 10 deletions

View File

@ -369,9 +369,9 @@ size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
ZSTD_inBuffer* input, ZSTD_inBuffer* input,
ZSTD_EndDirective const flushMode); ZSTD_EndDirective const flushMode);
/*! ZSTD_getParamsFromCDict() : /*! ZSTD_getCParamsFromCDict() :
* as the name implies */ * as the name implies */
ZSTD_CCtx_params ZSTD_getCCtxParamsFromCDict(const ZSTD_CDict* cdict); ZSTD_compressionParameters ZSTD_getCParamsFromCDict(const ZSTD_CDict* cdict);
/* INTERNAL */ /* INTERNAL */
size_t ZSTD_compressBegin_advanced_internal(ZSTD_CCtx* cctx, size_t ZSTD_compressBegin_advanced_internal(ZSTD_CCtx* cctx,

View File

@ -477,7 +477,7 @@ size_t ZSTD_CCtxParam_setParameter(
* This function should be updated whenever ZSTD_CCtx_params is updated. * This function should be updated whenever ZSTD_CCtx_params is updated.
* Parameters are copied manually before the dictionary is loaded. * Parameters are copied manually before the dictionary is loaded.
* The multithreading parameters jobSize and overlapSizeLog are set only if * The multithreading parameters jobSize and overlapSizeLog are set only if
* nbThreads >= 1. * nbThreads > 1.
* *
* Pledged srcSize is treated as unknown. * Pledged srcSize is treated as unknown.
*/ */
@ -3735,8 +3735,8 @@ ZSTD_CDict* ZSTD_initStaticCDict(void* workspace, size_t workspaceSize,
return cdict; return cdict;
} }
ZSTD_CCtx_params ZSTD_getCCtxParamsFromCDict(const ZSTD_CDict* cdict) { ZSTD_compressionParameters ZSTD_getCParamsFromCDict(const ZSTD_CDict* cdict) {
return cdict->refContext->appliedParams; return cdict->refContext->appliedParams.cParams;
} }
/* ZSTD_compressBegin_usingCDict_advanced() : /* ZSTD_compressBegin_usingCDict_advanced() :
@ -3746,7 +3746,8 @@ size_t ZSTD_compressBegin_usingCDict_advanced(
ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize) ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize)
{ {
if (cdict==NULL) return ERROR(dictionary_wrong); if (cdict==NULL) return ERROR(dictionary_wrong);
{ ZSTD_CCtx_params params = ZSTD_getCCtxParamsFromCDict(cdict); { ZSTD_CCtx_params params = cctx->requestedParams;
params.cParams = ZSTD_getCParamsFromCDict(cdict);
params.fParams = fParams; params.fParams = fParams;
params.dictMode = ZSTD_dm_auto; params.dictMode = ZSTD_dm_auto;
DEBUGLOG(5, "ZSTD_compressBegin_usingCDict_advanced"); DEBUGLOG(5, "ZSTD_compressBegin_usingCDict_advanced");
@ -3892,8 +3893,7 @@ size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,
if (zcs->cdictLocal == NULL) return ERROR(memory_allocation); if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
} else { } else {
if (cdict) { if (cdict) {
ZSTD_CCtx_params const cdictParams = ZSTD_getCCtxParamsFromCDict(cdict); params.cParams = ZSTD_getCParamsFromCDict(cdict); /* cParams are enforced from cdict */
params.cParams = cdictParams.cParams; /* cParams are enforced from cdict */
} }
ZSTD_freeCDict(zcs->cdictLocal); ZSTD_freeCDict(zcs->cdictLocal);
zcs->cdictLocal = NULL; zcs->cdictLocal = NULL;
@ -3914,7 +3914,8 @@ size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
unsigned long long pledgedSrcSize) unsigned long long pledgedSrcSize)
{ /* cannot handle NULL cdict (does not know what to do) */ { /* cannot handle NULL cdict (does not know what to do) */
if (!cdict) return ERROR(dictionary_wrong); if (!cdict) return ERROR(dictionary_wrong);
{ ZSTD_CCtx_params params = ZSTD_getCCtxParamsFromCDict(cdict); { ZSTD_CCtx_params params = zcs->requestedParams;
params.cParams = ZSTD_getCParamsFromCDict(cdict);
params.fParams = fParams; params.fParams = fParams;
return ZSTD_initCStream_internal(zcs, return ZSTD_initCStream_internal(zcs,
NULL, 0, cdict, NULL, 0, cdict,

View File

@ -817,7 +817,7 @@ size_t ZSTDMT_initCStream_usingCDict(ZSTDMT_CCtx* mtctx,
unsigned long long pledgedSrcSize) unsigned long long pledgedSrcSize)
{ {
ZSTD_CCtx_params cctxParams = mtctx->params; ZSTD_CCtx_params cctxParams = mtctx->params;
cctxParams.cParams = ZSTD_getCCtxParamsFromCDict(cdict).cParams; cctxParams.cParams = ZSTD_getCParamsFromCDict(cdict);
cctxParams.fParams = fParams; cctxParams.fParams = fParams;
if (cdict==NULL) return ERROR(dictionary_wrong); /* method incompatible with NULL cdict */ if (cdict==NULL) return ERROR(dictionary_wrong); /* method incompatible with NULL cdict */
return ZSTDMT_initCStream_internal(mtctx, NULL, 0 /*dictSize*/, cdict, return ZSTDMT_initCStream_internal(mtctx, NULL, 0 /*dictSize*/, cdict,