From: Bimba Shrestha Date: Fri, 3 Apr 2020 21:26:15 +0000 (-0700) Subject: moving consts to zstd_internal and reusing them X-Git-Tag: v1.4.5^2~67^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01548667491ff72d264b265f5ab8d3673487b9cf;p=thirdparty%2Fzstd.git moving consts to zstd_internal and reusing them --- diff --git a/lib/common/zstd_internal.h b/lib/common/zstd_internal.h index ce80f8c56..099a98e77 100644 --- a/lib/common/zstd_internal.h +++ b/lib/common/zstd_internal.h @@ -248,6 +248,16 @@ void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length, ZSTD_overlap_e } } +/* define "workspace is too large" as this number of times larger than needed */ +#define ZSTD_WORKSPACETOOLARGE_FACTOR 3 + +/* when workspace is continuously too large + * during at least this number of times, + * context's memory usage is considered wasteful, + * because it's sized to handle a worst case scenario which rarely happens. + * In which case, resize it down to free some memory */ +#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128 + /*-******************************************* * Private declarations diff --git a/lib/compress/zstd_cwksp.h b/lib/compress/zstd_cwksp.h index 2dfab3a4e..5886893d7 100644 --- a/lib/compress/zstd_cwksp.h +++ b/lib/compress/zstd_cwksp.h @@ -24,16 +24,6 @@ extern "C" { * Constants ***************************************/ -/* define "workspace is too large" as this number of times larger than needed */ -#define ZSTD_WORKSPACETOOLARGE_FACTOR 3 - -/* when workspace is continuously too large - * during at least this number of times, - * context's memory usage is considered wasteful, - * because it's sized to handle a worst case scenario which rarely happens. - * In which case, resize it down to free some memory */ -#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128 - /* Since the workspace is effectively its own little malloc implementation / * arena, when we run under ASAN, we should similarly insert redzones between * each internal element of the workspace, so ASAN will catch overruns that diff --git a/lib/decompress/zstd_decompress.c b/lib/decompress/zstd_decompress.c index c3690f022..754723042 100644 --- a/lib/decompress/zstd_decompress.c +++ b/lib/decompress/zstd_decompress.c @@ -1510,7 +1510,7 @@ MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src, static int ZSTD_DCtx_isOverflow(ZSTD_DStream* zds, size_t const neededInBuffSize, size_t const neededOutBuffSize) { - return (zds->inBuffSize + zds->outBuffSize) >= (neededInBuffSize + neededOutBuffSize) * ZSTD_OVERSIZED_FACTOR; + return (zds->inBuffSize + zds->outBuffSize) >= (neededInBuffSize + neededOutBuffSize) * ZSTD_WORKSPACETOOLARGE_FACTOR; } static void ZSTD_DCtx_updateOversizedDuration(ZSTD_DStream* zds, size_t const neededInBuffSize, size_t const neededOutBuffSize) @@ -1523,7 +1523,7 @@ static void ZSTD_DCtx_updateOversizedDuration(ZSTD_DStream* zds, size_t const ne static int ZSTD_DCtx_isOversizedTooLong(ZSTD_DStream* zds) { - return zds->oversizedDuration >= ZSTD_OVERSIZED_MAXDURATION; + return zds->oversizedDuration >= ZSTD_WORKSPACETOOLARGE_MAXDURATION; } size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input) diff --git a/lib/decompress/zstd_decompress_internal.h b/lib/decompress/zstd_decompress_internal.h index 68c313811..29b4d0acc 100644 --- a/lib/decompress/zstd_decompress_internal.h +++ b/lib/decompress/zstd_decompress_internal.h @@ -95,9 +95,6 @@ typedef enum { ZSTD_use_once = 1 /* Use the dictionary once and set to ZSTD_dont_use */ } ZSTD_dictUses_e; -#define ZSTD_OVERSIZED_MAXDURATION 128 -#define ZSTD_OVERSIZED_FACTOR 3 - struct ZSTD_DCtx_s { const ZSTD_seqSymbol* LLTptr;