diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index c8703719..c8cfd6c9 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -282,7 +282,12 @@ size_t ZSTD_resetCCtxParams(ZSTD_CCtx_params* params) return 0; } -size_t ZSTD_initCCtxParams(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params) +size_t ZSTD_initCCtxParams(ZSTD_CCtx_params* cctxParams, int compressionLevel) { + ZSTD_parameters const params = ZSTD_getParams(compressionLevel, 0, 0); + return ZSTD_initCCtxParams_advanced(cctxParams, params); +} + +size_t ZSTD_initCCtxParams_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params) { if (!cctxParams) { return ERROR(GENERIC); } CHECK_F( ZSTD_checkCParams(params.cParams) ); diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index 7c3bd019..c93d784d 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -584,7 +584,7 @@ static size_t ZSTDMT_compress_advanced_internal( size_t frameStartPos = 0, dstBufferPos = 0; XXH64_state_t xxh64; assert(jobParams.nbThreads == 0); - assert(mtctx->cctxPool.totalCCtx == params.nbThreads); + assert(mtctx->cctxPool->totalCCtx == params.nbThreads); DEBUGLOG(4, "nbChunks : %2u (chunkSize : %u bytes) ", nbChunks, (U32)avgChunkSize); if (nbChunks==1) { /* fallback to single-thread mode */ @@ -748,7 +748,7 @@ size_t ZSTDMT_initCStream_internal( /* params are supposed to be fully validated at this point */ assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams))); assert(!((dict) && (cdict))); /* either dict or cdict, not both */ - assert(mtctx->cctxPool.totalCCtx == params.nbThreads); + assert(zcs->cctxPool->totalCCtx == params.nbThreads); if (params.nbThreads==1) { ZSTD_CCtx_params const singleThreadParams = ZSTDMT_makeJobCCtxParams(params); diff --git a/lib/zstd.h b/lib/zstd.h index 01fbb18c..bfbe8284 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -1128,9 +1128,14 @@ ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void); ZSTDLIB_API size_t ZSTD_resetCCtxParams(ZSTD_CCtx_params* params); /*! ZSTD_initCCtxParams() : - * Set the compression and frame parameters of cctxParams according to params. - * All other parameters are reset to their default values. */ -ZSTDLIB_API size_t ZSTD_initCCtxParams(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params); + * Initializes the compression parameters of cctxParams according to + * compression level. All other parameters are reset to their default values. */ +ZSTDLIB_API size_t ZSTD_initCCtxParams(ZSTD_CCtx_params* cctxParams, int compressionLevel); + +/*! ZSTD_initCCtxParams_advanced() : + * Initializes the compression and frame parameters of cctxParams according to + * params. All other parameters are reset to their default values. */ +ZSTDLIB_API size_t ZSTD_initCCtxParams_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params); ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params);