diff options
author | W. Felix Handte <w@felixhandte.com> | 2018-04-11 20:55:12 (GMT) |
---|---|---|
committer | W. Felix Handte <w@felixhandte.com> | 2018-04-11 22:06:48 (GMT) |
commit | 51a56c47c0d34b6255bdd8e7b33f0ccb44b80351 (patch) | |
tree | 21b929d486f364e33d2cf48fd2a66c750b2cbd5e /lib/lz4.c | |
parent | 3a0c571272731166774405e1f96b3161827ca09f (diff) | |
download | lz4-51a56c47c0d34b6255bdd8e7b33f0ccb44b80351.zip lz4-51a56c47c0d34b6255bdd8e7b33f0ccb44b80351.tar.gz lz4-51a56c47c0d34b6255bdd8e7b33f0ccb44b80351.tar.bz2 |
Minor Fixes
Diffstat (limited to 'lib/lz4.c')
-rw-r--r-- | lib/lz4.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -1193,7 +1193,19 @@ int LZ4_loadDict (LZ4_stream_t* LZ4_dict, const char* dictionary, int dictSize) } void LZ4_attach_dictionary(LZ4_stream_t *working_stream, const LZ4_stream_t *dictionary_stream) { - working_stream->internal_donotuse.dictCtx = dictionary_stream != NULL ? &(dictionary_stream->internal_donotuse) : NULL; + if (dictionary_stream != NULL) { + /* If the current offset is zero, we will never look in the + * external dictionary context, since there is no value a table + * entry can take that indicate a miss. In that case, we need + * to bump the offset to something non-zero. + */ + if (working_stream->internal_donotuse.currentOffset == 0) { + working_stream->internal_donotuse.currentOffset = 64 KB; + } + working_stream->internal_donotuse.dictCtx = &(dictionary_stream->internal_donotuse); + } else { + working_stream->internal_donotuse.dictCtx = NULL; + } } @@ -1264,14 +1276,6 @@ int LZ4_compress_fast_continue (LZ4_stream_t* LZ4_stream, const char* source, ch memcpy(streamPtr, streamPtr->dictCtx, sizeof(LZ4_stream_t)); result = LZ4_compress_generic(streamPtr, source, dest, inputSize, maxOutputSize, limitedOutput, tableType, usingExtDict, noDictIssue, acceleration); } else { - /* If the current offset is zero, we will never look in the - * external dictionary context, since there is no value a table - * entry can take that indicate a miss. In that case, we need - * to bump the offset to something non-zero. - */ - if (streamPtr->currentOffset == 0) { - streamPtr->currentOffset = 64 KB; - } result = LZ4_compress_generic(streamPtr, source, dest, inputSize, maxOutputSize, limitedOutput, tableType, usingDictCtx, noDictIssue, acceleration); } } else { |