removed one useless streaming compression stage, detected by @terrelln

dev
Yann Collet 2017-06-20 16:25:29 -07:00
parent c3bce24ef4
commit 466f92eaa6
1 changed files with 5 additions and 7 deletions

View File

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