]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Use cctxParam version of createCDict internally
authorStella Lau <laus@fb.com>
Mon, 21 Aug 2017 18:00:44 +0000 (11:00 -0700)
committerStella Lau <laus@fb.com>
Mon, 21 Aug 2017 18:00:44 +0000 (11:00 -0700)
lib/common/zstd_internal.h
lib/compress/zstd_compress.c
lib/compress/zstdmt_compress.c

index ee3164183c73624c66cb188155e340770d8b3ed5..65719f5412605b6335ee41cbcc79baa007254360 100644 (file)
@@ -360,6 +360,11 @@ size_t ZSTD_initCStream_internal_opaque(
         ZSTD_CCtx_params  params,
         unsigned long long pledgedSrcSize);
 
+/* INTERNAL */
+ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
+        const void* dictBuffer, size_t dictSize,
+        ZSTD_CCtx_params params, ZSTD_customMem customMem);
+
 /*! ZSTD_compressStream_generic() :
  *  Private use only. To be called from zstdmt_compress.c in single-thread mode. */
 size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
index ee0365ca3048c847225eaeef7517872f29b0f216..265be326f37f12e8a8056447adce2d5f0e7980bc 100644 (file)
@@ -3698,7 +3698,8 @@ static size_t ZSTD_initCDict_internal(
 }
 #endif
 
-static ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
+/* Internal only */
+ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
         const void* dictBuffer, size_t dictSize,
         ZSTD_CCtx_params params, ZSTD_customMem customMem)
 {
@@ -3715,6 +3716,7 @@ static ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
         }
         cdict->refContext = cctx;
 
+        /* TODO: What should be zero? */
         if (ZSTD_isError( ZSTD_initCDict_internal_opaque(
                                         cdict,
                                         dictBuffer, dictSize,
@@ -3992,10 +3994,10 @@ size_t ZSTD_initCStream_internal_opaque(
             return ERROR(memory_allocation);
         }
         ZSTD_freeCDict(zcs->cdictLocal);
-        zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,
-                                            params.dictContentByRef,
-                                            params.dictMode,
-                                            params.cParams, zcs->customMem);
+        /* TODO opaque version: what needs to be zero? */
+        zcs->cdictLocal = ZSTD_createCDict_advanced_opaque(
+                                            dict, dictSize,
+                                            params, zcs->customMem);
         zcs->cdict = zcs->cdictLocal;
         if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
     } else {
index 84f42220cb997fd7edf9fa90085ef1baba753fce..e7a05f4b18ca484552f744b1cbfbfb0780b30116 100644 (file)
@@ -195,6 +195,7 @@ static void ZSTDMT_zeroCCtxParams(ZSTD_CCtx_params* params)
 {
     params->forceWindow = 0;
     params->dictMode = (ZSTD_dictMode_e)(0);
+    params->dictContentByRef = 0;
     params->nbThreads = 0;
     params->jobSize = 0;
     params->overlapSizeLog = 0;
@@ -719,13 +720,9 @@ size_t ZSTDMT_initCStream_internal_opaque(
         const ZSTD_CDict* cdict, ZSTD_CCtx_params cctxParams,
         unsigned long long pledgedSrcSize)
 {
-    ZSTD_parameters params;
-    params.cParams = cctxParams.cParams;
-    params.fParams = cctxParams.fParams;
-
     DEBUGLOG(4, "ZSTDMT_initCStream_internal");
     /* params are supposed to be fully validated at this point */
-    assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
+    assert(!ZSTD_isError(ZSTD_checkCParams(cctxParams.cParams)));
     assert(!((dict) && (cdict)));  /* either dict or cdict, not both */
 
     /* TODO: Set stuff to 0 to preserve old semantics. */
@@ -749,10 +746,11 @@ size_t ZSTDMT_initCStream_internal_opaque(
     if (dict) {
         DEBUGLOG(4,"cdictLocal: %08X", (U32)(size_t)zcs->cdictLocal);
         ZSTD_freeCDict(zcs->cdictLocal);
-        /* TODO: This will need a cctxParam version? */
-        zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,
-                                                    0 /* byRef */, ZSTD_dm_auto,   /* note : a loadPrefix becomes an internal CDict */
-                                                    params.cParams, zcs->cMem);
+        /* TODO: cctxParam version? Is this correct?
+         * by reference should be zero, mode should be ZSTD_dm_auto */
+        zcs->cdictLocal = ZSTD_createCDict_advanced_opaque(
+                                                    dict, dictSize,
+                                                    cctxParams, zcs->cMem);
         zcs->cdict = zcs->cdictLocal;
         if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
     } else {
@@ -777,7 +775,7 @@ size_t ZSTDMT_initCStream_internal_opaque(
     zcs->nextJobID = 0;
     zcs->frameEnded = 0;
     zcs->allJobsCompleted = 0;
-    if (params.fParams.checksumFlag) XXH64_reset(&zcs->xxhState, 0);
+    if (cctxParams.fParams.checksumFlag) XXH64_reset(&zcs->xxhState, 0);
     return 0;
 }