1
0
mirror of https://github.com/facebook/zstd.git synced 2025-03-07 01:10:04 +02:00

Migrate to FORWARD_IF_ERROR

This commit is contained in:
W. Felix Handte 2021-12-02 16:06:07 -05:00
parent a3ee9815c7
commit d82d67d073

View File

@ -15,6 +15,7 @@
***************************************/
#define ZBUFF_STATIC_LINKING_ONLY
#include "zbuff.h"
#include "error_private.h"
/*-***********************************************************
@ -72,36 +73,33 @@ size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
const void* dict, size_t dictSize,
ZSTD_parameters params, unsigned long long pledgedSrcSize)
{
size_t ret;
if (pledgedSrcSize==0) pledgedSrcSize = ZSTD_CONTENTSIZE_UNKNOWN; /* preserve "0 == unknown" behavior */
ret = ZSTD_CCtx_reset(zbc, ZSTD_reset_session_only);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setPledgedSrcSize(zbc, pledgedSrcSize);
FORWARD_IF_ERROR(ZSTD_CCtx_reset(zbc, ZSTD_reset_session_only), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setPledgedSrcSize(zbc, pledgedSrcSize), "");
ret = ZSTD_isError(ret) ? ret : ZSTD_checkCParams(params.cParams);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_windowLog, params.cParams.windowLog);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_hashLog, params.cParams.hashLog);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_chainLog, params.cParams.chainLog);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_searchLog, params.cParams.searchLog);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_minMatch, params.cParams.minMatch);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_targetLength, params.cParams.targetLength);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_strategy, params.cParams.strategy);
FORWARD_IF_ERROR(ZSTD_checkCParams(params.cParams), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_windowLog, params.cParams.windowLog), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_hashLog, params.cParams.hashLog), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_chainLog, params.cParams.chainLog), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_searchLog, params.cParams.searchLog), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_minMatch, params.cParams.minMatch), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_targetLength, params.cParams.targetLength), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_strategy, params.cParams.strategy), "");
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_contentSizeFlag, params.fParams.contentSizeFlag);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_checksumFlag, params.fParams.checksumFlag);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_dictIDFlag, params.fParams.noDictIDFlag);
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_contentSizeFlag, params.fParams.contentSizeFlag), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_checksumFlag, params.fParams.checksumFlag), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_dictIDFlag, params.fParams.noDictIDFlag), "");
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_loadDictionary(zbc, dict, dictSize);
return ZSTD_isError(ret) ? ret : 0;
FORWARD_IF_ERROR(ZSTD_CCtx_loadDictionary(zbc, dict, dictSize), "");
return 0;
}
size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* zbc, const void* dict, size_t dictSize, int compressionLevel)
{
size_t ret;
ret = ZSTD_CCtx_reset(zbc, ZSTD_reset_session_only);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_setParameter(zbc, ZSTD_c_compressionLevel, compressionLevel);
ret = ZSTD_isError(ret) ? ret : ZSTD_CCtx_loadDictionary(zbc, dict, dictSize);
return ZSTD_isError(ret) ? ret : 0;
FORWARD_IF_ERROR(ZSTD_CCtx_reset(zbc, ZSTD_reset_session_only), "");
FORWARD_IF_ERROR(ZSTD_CCtx_setParameter(zbc, ZSTD_c_compressionLevel, compressionLevel), "");
FORWARD_IF_ERROR(ZSTD_CCtx_loadDictionary(zbc, dict, dictSize), "");
return 0;
}
size_t ZBUFF_compressInit(ZBUFF_CCtx* zbc, int compressionLevel)