Implemented ZSTD_CCtx_refCDict()

This commit is contained in:
Yann Collet 2017-05-22 13:05:45 -07:00
parent ee970398b2
commit 24de7b0346
2 changed files with 7 additions and 9 deletions

View File

@ -228,9 +228,7 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned v
return ERROR(compressionParameter_unsupported); \
} }
if (cctx->streamStage != zcss_init) {
return ERROR(stage_wrong);
}
if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
switch(param)
{
@ -326,14 +324,14 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned v
ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize)
{
if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
cctx->frameContentSize = pledgedSrcSize;
return 0;
}
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize)
{
DEBUGLOG(5, "ZSTD_CCtx_loadDictionary : dictSize = %u",
(unsigned)dictSize);
if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
ZSTD_freeCDict(cctx->cdictLocal); /* in case one already exists */
if (dict==NULL || dictSize==0) { /* no dictionary mode */
cctx->cdictLocal = NULL;
@ -358,13 +356,14 @@ ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, s
ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize)
{
(void)cctx; (void)prefix; (void)prefixSize; /* to be done later */
if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
return ERROR(compressionParameter_unsupported);
}
/* Not ready yet ! */
ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict)
{
(void)cctx; (void)cdict; /* to be done later */
if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
cctx->cdict = cdict;
return ERROR(compressionParameter_unsupported);
}
@ -384,7 +383,6 @@ size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
return 0;
}
/** ZSTD_cycleLog() :
* condition for correct operation : hashLog > 1 */
static U32 ZSTD_cycleLog(U32 hashLog, ZSTD_strategy strat)

View File

@ -746,7 +746,7 @@ ZSTDLIB_API size_t ZSTD_CDict_loadDictionary(ZSTD_CDict* cdict, const void* dict
* Adding a new dictionary effectively "discards" any previous one.
* Note 2 : CDict is just referenced, its lifetime must outlive CCtx.
*/
ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /* Not ready yet ! */
ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);