]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Stop Allocating Extra Space for Table Redzones
authorW. Felix Handte <w@felixhandte.com>
Mon, 16 Sep 2019 22:06:16 +0000 (18:06 -0400)
committerW. Felix Handte <w@felixhandte.com>
Thu, 10 Oct 2019 17:40:16 +0000 (13:40 -0400)
lib/compress/zstd_compress.c
lib/compress/zstd_cwksp.h

index 5c73929086a9134c22b6e5ccadc1b8e939007b5f..110066731ec893596b42b15f0da811a3d47ee55e 100644 (file)
@@ -1077,9 +1077,9 @@ ZSTD_sizeof_matchState(const ZSTD_compressionParameters* const cParams,
     size_t const hSize = ((size_t)1) << cParams->hashLog;
     U32    const hashLog3 = (forCCtx && cParams->minMatch==3) ? MIN(ZSTD_HASHLOG3_MAX, cParams->windowLog) : 0;
     size_t const h3Size = hashLog3 ? ((size_t)1) << hashLog3 : 0;
-    size_t const tableSpace = ZSTD_cwksp_alloc_size(chainSize * sizeof(U32))
-                            + ZSTD_cwksp_alloc_size(hSize * sizeof(U32))
-                            + ZSTD_cwksp_alloc_size(h3Size * sizeof(U32));
+    size_t const tableSpace = chainSize * sizeof(U32)
+                            + hSize * sizeof(U32)
+                            + h3Size * sizeof(U32);
     size_t const optPotentialSpace =
         ZSTD_cwksp_alloc_size((MaxML+1) * sizeof(U32))
       + ZSTD_cwksp_alloc_size((MaxLL+1) * sizeof(U32))
index 2fca8cff2f2dd8ccad96de09475be42f0ae02ff1..15b48b47010777be1c9ed7ed4029a142a4b3d75d 100644 (file)
@@ -182,6 +182,10 @@ MEM_STATIC size_t ZSTD_cwksp_align(size_t size, size_t const align) {
  * allocate this object. (Normally it should be exactly the size of the object,
  * but under special conditions, like ASAN, where we pad each object, it might
  * be larger.)
+ *
+ * Since tables aren't currently redzoned, you don't need to call through this
+ * to figure out how much space you need for the matchState tables. Everything
+ * else is though.
  */
 MEM_STATIC size_t ZSTD_cwksp_alloc_size(size_t size) {
 #if defined (ADDRESS_SANITIZER) && !defined (ZSTD_ASAN_DONT_POISON_WORKSPACE)