Fix setParameter not falling back to default compression level on 0 value

See documentation for `ZSTD_c_compressionLevel`: `Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT`
This commit is contained in:
i-do-cpp 2020-08-31 09:25:43 +02:00 committed by GitHub
parent c6d5a2cad0
commit d514281e73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -540,7 +540,9 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams,
case ZSTD_c_compressionLevel : {
FORWARD_IF_ERROR(ZSTD_cParam_clampBounds(param, &value), "");
if (value) { /* 0 : does not change current level */
if (value == 0)
CCtxParams->compressionLevel = ZSTD_CLEVEL_DEFAULT; /* 0 == default */
else
CCtxParams->compressionLevel = value;
}
if (CCtxParams->compressionLevel >= 0) return (size_t)CCtxParams->compressionLevel;