diff --git a/lib/common/fse_decompress.c b/lib/common/fse_decompress.c index d0072a9f..601edd74 100644 --- a/lib/common/fse_decompress.c +++ b/lib/common/fse_decompress.c @@ -64,6 +64,7 @@ /* ************************************************************** * Error Management ****************************************************************/ +#define FSE_isError ERR_isError #define FSE_STATIC_ASSERT(c) { enum { FSE_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ diff --git a/lib/common/zstd_common.c b/lib/common/zstd_common.c index 9915da75..1b334088 100644 --- a/lib/common/zstd_common.c +++ b/lib/common/zstd_common.c @@ -30,17 +30,23 @@ */ -/* ************************************* +/*-************************************* * Dependencies ***************************************/ #include #include "mem.h" #include "fse_static.h" /* FSE_MIN_TABLELOG */ #include "error_private.h" -#include "zstd.h" /* declaration of ZSTD_isError, ZSTD_getErrorName */ +#include "zstd.h" /* declaration of ZSTD_isError, ZSTD_getErrorName */ #include "zbuff.h" /* declaration of ZBUFF_isError, ZBUFF_getErrorName */ -#include "fse.h" /* declaration of FSE_isError, FSE_getErrorName */ -#include "huf.h" /* declaration of HUF_isError, HUF_getErrorName */ +#include "fse.h" /* declaration of FSE_isError, FSE_getErrorName */ +#include "huf.h" /* declaration of HUF_isError, HUF_getErrorName */ + + +/*-**************************************** +* Version +******************************************/ +unsigned ZSTD_versionNumber (void) { return ZSTD_VERSION_NUMBER; } /*-**************************************** @@ -50,16 +56,16 @@ * tells if a return value is an error code */ unsigned ZSTD_isError(size_t code) { return ERR_isError(code); } +/*! ZSTD_getErrorName() : +* provides error code string from function result (useful for debugging) */ +const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); } + /*! ZSTD_getError() : * convert a `size_t` function result into a proper ZSTD_errorCode enum */ ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); } -/*! ZSTD_getErrorName() : -* provides error code string (useful for debugging) */ -const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); } - -/*! ZSTD_getErrorName() : -* provides error code string (useful for debugging) */ +/*! ZSTD_getErrorString() : +* provides error code string from enum */ const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorName(code); } @@ -88,7 +94,7 @@ const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(error /*-************************************************************** -* FSE NCount encoding-decoding +* FSE NCount decoding ****************************************************************/ static short FSE_abs(short a) { return a<0 ? -a : a; } @@ -175,7 +181,7 @@ size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* t ip = iend - 4; } bitStream = MEM_readLE32(ip) >> (bitCount & 31); - } } + } } /* while ((remaining>1) && (charnum<=*maxSVPtr)) */ if (remaining != 1) return ERROR(GENERIC); *maxSVPtr = charnum-1; diff --git a/lib/decompress/zstd_decompress.c b/lib/decompress/zstd_decompress.c index f29560e9..177e9c8a 100644 --- a/lib/decompress/zstd_decompress.c +++ b/lib/decompress/zstd_decompress.c @@ -83,18 +83,20 @@ #endif +/*-************************************* +* Macros +***************************************/ +#define ZSTD_isError ERR_isError /* for inlining */ +#define FSE_isError ERR_isError +#define HUF_isError ERR_isError + + /*_******************************************************* * Memory operations **********************************************************/ static void ZSTD_copy4(void* dst, const void* src) { memcpy(dst, src, 4); } -/*-************************************* -* Error Management -***************************************/ -unsigned ZSTD_versionNumber (void) { return ZSTD_VERSION_NUMBER; } - - /*-************************************************************* * Context management ***************************************************************/