summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2018-04-11 20:55:12 (GMT)
committerW. Felix Handte <w@felixhandte.com>2018-04-11 22:06:48 (GMT)
commit51a56c47c0d34b6255bdd8e7b33f0ccb44b80351 (patch)
tree21b929d486f364e33d2cf48fd2a66c750b2cbd5e
parent3a0c571272731166774405e1f96b3161827ca09f (diff)
downloadlz4-51a56c47c0d34b6255bdd8e7b33f0ccb44b80351.zip
lz4-51a56c47c0d34b6255bdd8e7b33f0ccb44b80351.tar.gz
lz4-51a56c47c0d34b6255bdd8e7b33f0ccb44b80351.tar.bz2
Minor Fixes
-rw-r--r--lib/lz4.c22
-rw-r--r--lib/lz4frame.c2
2 files changed, 13 insertions, 11 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 9e6b1e2..111085a 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -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 {
diff --git a/lib/lz4frame.c b/lib/lz4frame.c
index 7608d90..507e4fe 100644
--- a/lib/lz4frame.c
+++ b/lib/lz4frame.c
@@ -531,8 +531,6 @@ static void LZ4F_applyCDict(void* ctx,
const LZ4F_CDict* cdict,
int level) {
if (level < LZ4HC_CLEVEL_MIN) {
- LZ4_stream_t_internal* internal_ctx = &((LZ4_stream_t *)ctx)->internal_donotuse;
- assert(!internal_ctx->initCheck);
LZ4_resetStream_fast((LZ4_stream_t *)ctx);
LZ4_attach_dictionary((LZ4_stream_t *)ctx, cdict ? cdict->fastCtx : NULL);
} else {