]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix parameter retrieval from cdict
authorStella Lau <laus@fb.com>
Sat, 26 Aug 2017 00:58:28 +0000 (17:58 -0700)
committerStella Lau <laus@fb.com>
Sat, 26 Aug 2017 00:58:28 +0000 (17:58 -0700)
lib/common/zstd_internal.h
lib/compress/zstd_compress.c
lib/compress/zstdmt_compress.c

index 53de69739e68226ae1a006491d21417b19d6f34b..bfec42fad7b942fa008db691b99d03e837f50e16 100644 (file)
@@ -369,9 +369,9 @@ size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
                                    ZSTD_inBuffer* input,
                                    ZSTD_EndDirective const flushMode);
 
-/*! ZSTD_getParamsFromCDict() :
+/*! ZSTD_getCParamsFromCDict() :
  *  as the name implies */
-ZSTD_CCtx_params ZSTD_getCCtxParamsFromCDict(const ZSTD_CDict* cdict);
+ZSTD_compressionParameters ZSTD_getCParamsFromCDict(const ZSTD_CDict* cdict);
 
 /* INTERNAL */
 size_t ZSTD_compressBegin_advanced_internal(ZSTD_CCtx* cctx,
index 6f4121c758dec48b26ad7b7dc1fd8dca146a9b26..1f570a92a81242ab385da66dae00509386499e5f 100644 (file)
@@ -477,7 +477,7 @@ size_t ZSTD_CCtxParam_setParameter(
  * This function should be updated whenever ZSTD_CCtx_params is updated.
  * Parameters are copied manually before the dictionary is loaded.
  * The multithreading parameters jobSize and overlapSizeLog are set only if
- * nbThreads >= 1.
+ * nbThreads > 1.
  *
  * Pledged srcSize is treated as unknown.
  */
@@ -3735,8 +3735,8 @@ ZSTD_CDict* ZSTD_initStaticCDict(void* workspace, size_t workspaceSize,
     return cdict;
 }
 
-ZSTD_CCtx_params ZSTD_getCCtxParamsFromCDict(const ZSTD_CDict* cdict) {
-    return cdict->refContext->appliedParams;
+ZSTD_compressionParameters ZSTD_getCParamsFromCDict(const ZSTD_CDict* cdict) {
+    return cdict->refContext->appliedParams.cParams;
 }
 
 /* ZSTD_compressBegin_usingCDict_advanced() :
@@ -3746,7 +3746,8 @@ size_t ZSTD_compressBegin_usingCDict_advanced(
     ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize)
 {
     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.dictMode = ZSTD_dm_auto;
         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);
     } else {
         if (cdict) {
-            ZSTD_CCtx_params const cdictParams = ZSTD_getCCtxParamsFromCDict(cdict);
-            params.cParams = cdictParams.cParams;  /* cParams are enforced from cdict */
+            params.cParams = ZSTD_getCParamsFromCDict(cdict);  /* cParams are enforced from cdict */
         }
         ZSTD_freeCDict(zcs->cdictLocal);
         zcs->cdictLocal = NULL;
@@ -3914,7 +3914,8 @@ size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
                                             unsigned long long pledgedSrcSize)
 {   /* cannot handle NULL cdict (does not know what to do) */
     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;
         return ZSTD_initCStream_internal(zcs,
                                 NULL, 0, cdict,
index 8687ea3c0f1438b3dbe16b88853198c6eff8207a..b1a681e74ea9d5a6d5ffd6e26b5a1e129afd04db 100644 (file)
@@ -817,7 +817,7 @@ size_t ZSTDMT_initCStream_usingCDict(ZSTDMT_CCtx* mtctx,
                                      unsigned long long pledgedSrcSize)
 {
     ZSTD_CCtx_params cctxParams = mtctx->params;
-    cctxParams.cParams = ZSTD_getCCtxParamsFromCDict(cdict).cParams;
+    cctxParams.cParams = ZSTD_getCParamsFromCDict(cdict);
     cctxParams.fParams = fParams;
     if (cdict==NULL) return ERROR(dictionary_wrong);   /* method incompatible with NULL cdict */
     return ZSTDMT_initCStream_internal(mtctx, NULL, 0 /*dictSize*/, cdict,