From: Yann Collet Date: Tue, 20 Jun 2017 23:25:29 +0000 (-0700) Subject: removed one useless streaming compression stage, detected by @terrelln X-Git-Tag: v1.3.0~1^2~17^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=466f92eaa643271ec1b537bc11e47bda5c96c121;p=thirdparty%2Fzstd.git removed one useless streaming compression stage, detected by @terrelln --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 7c4b526e2..e48bc41bd 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -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); }