mirror of
https://github.com/facebook/zstd.git
synced 2025-10-09 00:05:28 -04:00
Use cctxParam version of createCDict internally
This commit is contained in:
parent
91b30dbe84
commit
502031ca10
@ -360,6 +360,11 @@ size_t ZSTD_initCStream_internal_opaque(
|
|||||||
ZSTD_CCtx_params params,
|
ZSTD_CCtx_params params,
|
||||||
unsigned long long pledgedSrcSize);
|
unsigned long long pledgedSrcSize);
|
||||||
|
|
||||||
|
/* INTERNAL */
|
||||||
|
ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
|
||||||
|
const void* dictBuffer, size_t dictSize,
|
||||||
|
ZSTD_CCtx_params params, ZSTD_customMem customMem);
|
||||||
|
|
||||||
/*! ZSTD_compressStream_generic() :
|
/*! ZSTD_compressStream_generic() :
|
||||||
* Private use only. To be called from zstdmt_compress.c in single-thread mode. */
|
* Private use only. To be called from zstdmt_compress.c in single-thread mode. */
|
||||||
size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
|
size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
|
||||||
|
@ -3698,7 +3698,8 @@ static size_t ZSTD_initCDict_internal(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
|
/* Internal only */
|
||||||
|
ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
|
||||||
const void* dictBuffer, size_t dictSize,
|
const void* dictBuffer, size_t dictSize,
|
||||||
ZSTD_CCtx_params params, ZSTD_customMem customMem)
|
ZSTD_CCtx_params params, ZSTD_customMem customMem)
|
||||||
{
|
{
|
||||||
@ -3715,6 +3716,7 @@ static ZSTD_CDict* ZSTD_createCDict_advanced_opaque(
|
|||||||
}
|
}
|
||||||
cdict->refContext = cctx;
|
cdict->refContext = cctx;
|
||||||
|
|
||||||
|
/* TODO: What should be zero? */
|
||||||
if (ZSTD_isError( ZSTD_initCDict_internal_opaque(
|
if (ZSTD_isError( ZSTD_initCDict_internal_opaque(
|
||||||
cdict,
|
cdict,
|
||||||
dictBuffer, dictSize,
|
dictBuffer, dictSize,
|
||||||
@ -3992,10 +3994,10 @@ size_t ZSTD_initCStream_internal_opaque(
|
|||||||
return ERROR(memory_allocation);
|
return ERROR(memory_allocation);
|
||||||
}
|
}
|
||||||
ZSTD_freeCDict(zcs->cdictLocal);
|
ZSTD_freeCDict(zcs->cdictLocal);
|
||||||
zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,
|
/* TODO opaque version: what needs to be zero? */
|
||||||
params.dictContentByRef,
|
zcs->cdictLocal = ZSTD_createCDict_advanced_opaque(
|
||||||
params.dictMode,
|
dict, dictSize,
|
||||||
params.cParams, zcs->customMem);
|
params, zcs->customMem);
|
||||||
zcs->cdict = zcs->cdictLocal;
|
zcs->cdict = zcs->cdictLocal;
|
||||||
if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
|
if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
|
||||||
} else {
|
} else {
|
||||||
|
@ -195,6 +195,7 @@ static void ZSTDMT_zeroCCtxParams(ZSTD_CCtx_params* params)
|
|||||||
{
|
{
|
||||||
params->forceWindow = 0;
|
params->forceWindow = 0;
|
||||||
params->dictMode = (ZSTD_dictMode_e)(0);
|
params->dictMode = (ZSTD_dictMode_e)(0);
|
||||||
|
params->dictContentByRef = 0;
|
||||||
params->nbThreads = 0;
|
params->nbThreads = 0;
|
||||||
params->jobSize = 0;
|
params->jobSize = 0;
|
||||||
params->overlapSizeLog = 0;
|
params->overlapSizeLog = 0;
|
||||||
@ -719,13 +720,9 @@ size_t ZSTDMT_initCStream_internal_opaque(
|
|||||||
const ZSTD_CDict* cdict, ZSTD_CCtx_params cctxParams,
|
const ZSTD_CDict* cdict, ZSTD_CCtx_params cctxParams,
|
||||||
unsigned long long pledgedSrcSize)
|
unsigned long long pledgedSrcSize)
|
||||||
{
|
{
|
||||||
ZSTD_parameters params;
|
|
||||||
params.cParams = cctxParams.cParams;
|
|
||||||
params.fParams = cctxParams.fParams;
|
|
||||||
|
|
||||||
DEBUGLOG(4, "ZSTDMT_initCStream_internal");
|
DEBUGLOG(4, "ZSTDMT_initCStream_internal");
|
||||||
/* params are supposed to be fully validated at this point */
|
/* params are supposed to be fully validated at this point */
|
||||||
assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
|
assert(!ZSTD_isError(ZSTD_checkCParams(cctxParams.cParams)));
|
||||||
assert(!((dict) && (cdict))); /* either dict or cdict, not both */
|
assert(!((dict) && (cdict))); /* either dict or cdict, not both */
|
||||||
|
|
||||||
/* TODO: Set stuff to 0 to preserve old semantics. */
|
/* TODO: Set stuff to 0 to preserve old semantics. */
|
||||||
@ -749,10 +746,11 @@ size_t ZSTDMT_initCStream_internal_opaque(
|
|||||||
if (dict) {
|
if (dict) {
|
||||||
DEBUGLOG(4,"cdictLocal: %08X", (U32)(size_t)zcs->cdictLocal);
|
DEBUGLOG(4,"cdictLocal: %08X", (U32)(size_t)zcs->cdictLocal);
|
||||||
ZSTD_freeCDict(zcs->cdictLocal);
|
ZSTD_freeCDict(zcs->cdictLocal);
|
||||||
/* TODO: This will need a cctxParam version? */
|
/* TODO: cctxParam version? Is this correct?
|
||||||
zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,
|
* by reference should be zero, mode should be ZSTD_dm_auto */
|
||||||
0 /* byRef */, ZSTD_dm_auto, /* note : a loadPrefix becomes an internal CDict */
|
zcs->cdictLocal = ZSTD_createCDict_advanced_opaque(
|
||||||
params.cParams, zcs->cMem);
|
dict, dictSize,
|
||||||
|
cctxParams, zcs->cMem);
|
||||||
zcs->cdict = zcs->cdictLocal;
|
zcs->cdict = zcs->cdictLocal;
|
||||||
if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
|
if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
|
||||||
} else {
|
} else {
|
||||||
@ -777,7 +775,7 @@ size_t ZSTDMT_initCStream_internal_opaque(
|
|||||||
zcs->nextJobID = 0;
|
zcs->nextJobID = 0;
|
||||||
zcs->frameEnded = 0;
|
zcs->frameEnded = 0;
|
||||||
zcs->allJobsCompleted = 0;
|
zcs->allJobsCompleted = 0;
|
||||||
if (params.fParams.checksumFlag) XXH64_reset(&zcs->xxhState, 0);
|
if (cctxParams.fParams.checksumFlag) XXH64_reset(&zcs->xxhState, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user