summaryrefslogtreecommitdiffstats
path: root/lib/lz4.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2016-11-10 23:31:59 (GMT)
committerYann Collet <cyan@fb.com>2016-11-10 23:31:59 (GMT)
commit1f246a98992fa7035823bedf6a0b7612fc290592 (patch)
tree2798ea12ec7cc812dfc5befbf9121939fc9d7938 /lib/lz4.c
parent5e13a6ec469e25c7dd425c7da4518b4ad2a8862d (diff)
downloadlz4-1f246a98992fa7035823bedf6a0b7612fc290592.zip
lz4-1f246a98992fa7035823bedf6a0b7612fc290592.tar.gz
lz4-1f246a98992fa7035823bedf6a0b7612fc290592.tar.bz2
Fixed #178 fullbench on small input
Diffstat (limited to 'lib/lz4.c')
-rw-r--r--lib/lz4.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 53b503c..f86e6f8 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -1066,10 +1066,17 @@ int LZ4_compress_forceExtDict (LZ4_stream_t* LZ4_dict, const char* source, char*
}
+/*! LZ4_saveDict() :
+ * If previously compressed data block is not guaranteed to remain available at its memory location,
+ * save it into a safer place (char* safeBuffer).
+ * Note : you don't need to call LZ4_loadDict() afterwards,
+ * dictionary is immediately usable, you can therefore call LZ4_compress_fast_continue().
+ * Return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error.
+ */
int LZ4_saveDict (LZ4_stream_t* LZ4_dict, char* safeBuffer, int dictSize)
{
- LZ4_stream_t_internal* dict = (LZ4_stream_t_internal*) LZ4_dict;
- const BYTE* previousDictEnd = dict->dictionary + dict->dictSize;
+ LZ4_stream_t_internal* const dict = (LZ4_stream_t_internal*) LZ4_dict;
+ const BYTE* const previousDictEnd = dict->dictionary + dict->dictSize;
if ((U32)dictSize > 64 KB) dictSize = 64 KB; /* useless to define a dictionary > 64 KB */
if ((U32)dictSize > dict->dictSize) dictSize = dict->dictSize;