]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
init entropy table pointers only once
authorYann Collet <cyan@fb.com>
Fri, 21 Apr 2017 00:38:56 +0000 (17:38 -0700)
committerYann Collet <cyan@fb.com>
Fri, 21 Apr 2017 00:38:56 +0000 (17:38 -0700)
per workSpace resize

lib/compress/zstd_compress.c

index e049aa07665c60f48aedb2b7a79379c147254a3d..ac0519fbafb937f79e7389b2f9ec1ef54cafa5fe 100644 (file)
@@ -294,6 +294,12 @@ static size_t ZSTD_resetCCtx_internal (ZSTD_CCtx* zc,
                 zc->workSpace = ZSTD_malloc(neededSpace, zc->customMem);
                 if (zc->workSpace == NULL) return ERROR(memory_allocation);
                 zc->workSpaceSize = neededSpace;
+                ptr = zc->workSpace;
+
+                /* entropy space */
+                zc->hufTable = (HUF_CElt*)ptr;
+                ptr = (U32*)zc->hufTable + HUF_CTABLE_SIZE_U32(255);  /* note : HUF_CElt* is incomplete type, size is estimated via macro */
+
         }   }
 
         /* init params */
@@ -318,10 +324,6 @@ static size_t ZSTD_resetCCtx_internal (ZSTD_CCtx* zc,
         zc->hashLog3 = hashLog3;
         zc->seqStore.litLengthSum = 0;
 
-        ptr = zc->workSpace;
-
-        /* entropy space */
-        zc->hufTable = (HUF_CElt*)ptr;
         ptr = (U32*)zc->hufTable + HUF_CTABLE_SIZE_U32(255);  /* note : HUF_CElt* is incomplete type, size is estimated via macro */
 
         /* opt parser space */