]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
moving consts to zstd_internal and reusing them
authorBimba Shrestha <bimbashrestha@fb.com>
Fri, 3 Apr 2020 21:26:15 +0000 (14:26 -0700)
committerBimba Shrestha <bimbashrestha@fb.com>
Fri, 3 Apr 2020 21:26:15 +0000 (14:26 -0700)
lib/common/zstd_internal.h
lib/compress/zstd_cwksp.h
lib/decompress/zstd_decompress.c
lib/decompress/zstd_decompress_internal.h

index ce80f8c56397522ced6121b2c3faab0cc73f028b..099a98e7744fb7277db42e06c0d2228b79c4cfc5 100644 (file)
@@ -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
index 2dfab3a4e3edf40ef2024bf743b4fe4ca5e73dfe..5886893d7118b9048cc284fd8f4fb5f54caf6b0b 100644 (file)
@@ -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
index c3690f022a13955cd70c6ee1788b7caa523a90c2..7547230428c3ff948eeb54bfa5e90da1b5871013 100644 (file)
@@ -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)
index 68c31381130f55c2cacc0982e30edd6338a2caf7..29b4d0acc21b15f103058cf26e18919ca5dbbebe 100644 (file)
@@ -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;