summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2018-03-28 16:25:05 (GMT)
committerW. Felix Handte <w@felixhandte.com>2018-04-20 00:54:35 (GMT)
commit4f7b7a8ffa3032a64aa173f7d8bfb7c258316154 (patch)
tree59f4c507d02e46e7d2c2495a522580a6de3f0708 /lib
parentb88a0b4e8812777d1e715ab095738197f7f8eb96 (diff)
downloadlz4-4f7b7a8ffa3032a64aa173f7d8bfb7c258316154.zip
lz4-4f7b7a8ffa3032a64aa173f7d8bfb7c258316154.tar.gz
lz4-4f7b7a8ffa3032a64aa173f7d8bfb7c258316154.tar.bz2
Clear Tables on Dict Load
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4hc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index e005cd7..85419f3 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -95,6 +95,12 @@ static void LZ4HC_init (LZ4HC_CCtx_internal* hc4, const BYTE* start)
hc4->lowLimit = 64 KB;
}
+static void LZ4HC_clearTables (LZ4HC_CCtx_internal* hc4)
+{
+ MEM_INIT((void*)hc4->hashTable, 0, sizeof(hc4->hashTable));
+ MEM_INIT(hc4->chainTable, 0xFF, sizeof(hc4->chainTable));
+}
+
/* Update chains up to ip (excluded) */
LZ4_FORCE_INLINE void LZ4HC_Insert (LZ4HC_CCtx_internal* hc4, const BYTE* ip)
@@ -782,6 +788,7 @@ int LZ4_loadDictHC (LZ4_streamHC_t* LZ4_streamHCPtr, const char* dictionary, int
dictSize = 64 KB;
}
LZ4HC_init (ctxPtr, (const BYTE*)dictionary);
+ LZ4HC_clearTables (ctxPtr);
ctxPtr->end = (const BYTE*)dictionary + dictSize;
if (dictSize >= 4) LZ4HC_Insert (ctxPtr, ctxPtr->end-3);
return dictSize;