mirror of
https://github.com/facebook/zstd.git
synced 2025-10-10 00:03:36 -04:00
Merge pull request #1549 from terrelln/ref-cdict-free
[libzstd] Free local cdict when referencing cdict
This commit is contained in:
commit
ea3b81f02c
@ -839,6 +839,9 @@ ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, s
|
|||||||
size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict)
|
size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict)
|
||||||
{
|
{
|
||||||
RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong);
|
RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong);
|
||||||
|
/* Free the existing local cdict (if any) to save memory. */
|
||||||
|
FORWARD_IF_ERROR( ZSTD_freeCDict(cctx->cdictLocal) );
|
||||||
|
cctx->cdictLocal = NULL;
|
||||||
cctx->cdict = cdict;
|
cctx->cdict = cdict;
|
||||||
memset(&cctx->prefixDict, 0, sizeof(cctx->prefixDict)); /* exclusive */
|
memset(&cctx->prefixDict, 0, sizeof(cctx->prefixDict)); /* exclusive */
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user