/*-*************************************
* 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;
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) {
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;
}
break;
}
- case zcss_final:
- someMoreWork = 0; break; /* useless */
-
default: /* impossible */
assert(0);
}