mirror of
https://github.com/facebook/zstd.git
synced 2025-11-28 00:04:28 -05:00
moving consts to zstd_internal and reusing them
This commit is contained in:
parent
0a172c5e43
commit
0154866749
@ -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
|
* Private declarations
|
||||||
|
|||||||
@ -24,16 +24,6 @@ extern "C" {
|
|||||||
* Constants
|
* 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 /
|
/* Since the workspace is effectively its own little malloc implementation /
|
||||||
* arena, when we run under ASAN, we should similarly insert redzones between
|
* arena, when we run under ASAN, we should similarly insert redzones between
|
||||||
* each internal element of the workspace, so ASAN will catch overruns that
|
* each internal element of the workspace, so ASAN will catch overruns that
|
||||||
|
|||||||
@ -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)
|
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)
|
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)
|
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)
|
size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
|
||||||
|
|||||||
@ -95,9 +95,6 @@ typedef enum {
|
|||||||
ZSTD_use_once = 1 /* Use the dictionary once and set to ZSTD_dont_use */
|
ZSTD_use_once = 1 /* Use the dictionary once and set to ZSTD_dont_use */
|
||||||
} ZSTD_dictUses_e;
|
} ZSTD_dictUses_e;
|
||||||
|
|
||||||
#define ZSTD_OVERSIZED_MAXDURATION 128
|
|
||||||
#define ZSTD_OVERSIZED_FACTOR 3
|
|
||||||
|
|
||||||
struct ZSTD_DCtx_s
|
struct ZSTD_DCtx_s
|
||||||
{
|
{
|
||||||
const ZSTD_seqSymbol* LLTptr;
|
const ZSTD_seqSymbol* LLTptr;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user