Add ZSTD_set{C,F,}Params() helper functions
* Add ZSTD_setFParams() and ZSTD_setParams() * Modify ZSTD_setCParams() to use ZSTD_setParameter() to avoid a second path setting parameters * Add unit tests * Update documentation to suggest using them to replace deprecated functions Fixes #3396.
This commit is contained in:
committed by
Nick Terrell
parent
6313a58e45
commit
07a2a33135
+20
-12
@@ -1803,12 +1803,26 @@ ZSTDLIB_STATIC_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
|
||||
ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
|
||||
|
||||
/*! ZSTD_CCtx_setCParams() :
|
||||
* Set all parameters provided within @cparams into the working @cctx.
|
||||
* Set all parameters provided within @p cparams into the working @p cctx.
|
||||
* Note : if modifying parameters during compression (MT mode only),
|
||||
* note that changes to the .windowLog parameter will be ignored.
|
||||
* @return 0 on success, or an error code (can be checked with ZSTD_isError()) */
|
||||
* @return 0 on success, or an error code (can be checked with ZSTD_isError()).
|
||||
* On failure, no parameters are updated.
|
||||
*/
|
||||
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setCParams(ZSTD_CCtx* cctx, ZSTD_compressionParameters cparams);
|
||||
|
||||
/*! ZSTD_CCtx_setFParams() :
|
||||
* Set all parameters provided within @p fparams into the working @p cctx.
|
||||
* @return 0 on success, or an error code (can be checked with ZSTD_isError()).
|
||||
*/
|
||||
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setFParams(ZSTD_CCtx* cctx, ZSTD_frameParameters fparams);
|
||||
|
||||
/*! ZSTD_CCtx_setParams() :
|
||||
* Set all parameters provided within @p params into the working @p cctx.
|
||||
* @return 0 on success, or an error code (can be checked with ZSTD_isError()).
|
||||
*/
|
||||
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setParams(ZSTD_CCtx* cctx, ZSTD_parameters params);
|
||||
|
||||
/*! ZSTD_compress_advanced() :
|
||||
* Note : this function is now DEPRECATED.
|
||||
* It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_setParameter() and other parameter setters.
|
||||
@@ -2452,12 +2466,9 @@ size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
|
||||
int compressionLevel);
|
||||
|
||||
/*! ZSTD_initCStream_advanced() :
|
||||
* This function is DEPRECATED, and is approximately equivalent to:
|
||||
* This function is DEPRECATED, and is equivalent to:
|
||||
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
||||
* // Pseudocode: Set each zstd parameter and leave the rest as-is.
|
||||
* for ((param, value) : params) {
|
||||
* ZSTD_CCtx_setParameter(zcs, param, value);
|
||||
* }
|
||||
* ZSTD_CCtx_setParams(zcs, params);
|
||||
* ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize);
|
||||
* ZSTD_CCtx_loadDictionary(zcs, dict, dictSize);
|
||||
*
|
||||
@@ -2486,12 +2497,9 @@ ZSTDLIB_STATIC_API
|
||||
size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict);
|
||||
|
||||
/*! ZSTD_initCStream_usingCDict_advanced() :
|
||||
* This function is DEPRECATED, and is approximately equivalent to:
|
||||
* This function is DEPRECATED, and is equivalent to:
|
||||
* ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
|
||||
* // Pseudocode: Set each zstd frame parameter and leave the rest as-is.
|
||||
* for ((fParam, value) : fParams) {
|
||||
* ZSTD_CCtx_setParameter(zcs, fParam, value);
|
||||
* }
|
||||
* ZSTD_CCtx_setFParams(zcs, fParams);
|
||||
* ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize);
|
||||
* ZSTD_CCtx_refCDict(zcs, cdict);
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user