]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
removed one useless streaming compression stage, detected by @terrelln
authorYann Collet <cyan@fb.com>
Tue, 20 Jun 2017 23:25:29 +0000 (16:25 -0700)
committerYann Collet <cyan@fb.com>
Tue, 20 Jun 2017 23:25:29 +0000 (16:25 -0700)
lib/compress/zstd_compress.c

index 7c4b526e28fd56a1a97c67847b26af55dc49b40a..e48bc41bdc034a00483e3574c819751f101405d1 100644 (file)
@@ -68,7 +68,7 @@ static void ZSTD_resetSeqStore(seqStore_t* ssPtr)
 /*-*************************************
 *  Context memory management
 ***************************************/
-typedef enum { zcss_init=0, zcss_load, zcss_flush, zcss_final } ZSTD_cStreamStage;
+typedef enum { zcss_init=0, zcss_load, zcss_flush } ZSTD_cStreamStage;
 
 struct ZSTD_CDict_s {
     void* dictBuffer;
@@ -3371,7 +3371,7 @@ ZSTD_CDict* ZSTD_createCDict_advanced(const void* dictBuffer, size_t dictSize, u
     DEBUGLOG(5, "ZSTD_createCDict_advanced");
     if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
 
-    {   ZSTD_CDict* const cdict = (ZSTD_CDict*) ZSTD_malloc(sizeof(ZSTD_CDict), customMem);
+    {   ZSTD_CDict* const cdict = (ZSTD_CDict*)ZSTD_malloc(sizeof(ZSTD_CDict), customMem);
         ZSTD_CCtx* const cctx = ZSTD_createCCtx_advanced(customMem);
 
         if (!cdict || !cctx) {
@@ -3588,15 +3588,16 @@ size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,
             return ERROR(memory_allocation);
         }
         ZSTD_freeCDict(zcs->cdictLocal);
-        zcs->cdict = NULL;
         zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize, 0 /* copy */, params.cParams, zcs->customMem);
-        if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
         zcs->cdict = zcs->cdictLocal;
+        if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
     } else {
         if (cdict) {
             ZSTD_parameters const cdictParams = ZSTD_getParamsFromCDict(cdict);
             params.cParams = cdictParams.cParams;  /* cParams are enforced from cdict */
         }
+        ZSTD_freeCDict(zcs->cdictLocal);
+        zcs->cdictLocal = NULL;
         zcs->cdict = cdict;
     }
 
@@ -3779,9 +3780,6 @@ static size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
                 break;
             }
 
-        case zcss_final:
-            someMoreWork = 0; break;  /* useless */
-
         default: /* impossible */
             assert(0);
         }