summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2014-06-02 07:13:16 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2014-06-02 07:13:16 (GMT)
commitec717699c7841b4471ee6566d80f4835ace8438b (patch)
treea97733056007e54243899d68ab2c496e50cfb552
parentb636779b0e168c346b42e85af816ce37a8ed9880 (diff)
downloadlz4-ec717699c7841b4471ee6566d80f4835ace8438b.zip
lz4-ec717699c7841b4471ee6566d80f4835ace8438b.tar.gz
lz4-ec717699c7841b4471ee6566d80f4835ace8438b.tar.bz2
restored continuous streaming mode
-rwxr-xr-xlz4.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/lz4.c b/lz4.c
index ec0f1b0..4c84e92 100755
--- a/lz4.c
+++ b/lz4.c
@@ -738,33 +738,48 @@ void LZ4_renormDictT(LZ4_dict_t_internal* LZ4_dict)
int LZ4_compress_usingDict (LZ4_dict_t* LZ4_dict, const char* source, char* dest, int inputSize)
{
LZ4_dict_t_internal* streamPtr = (LZ4_dict_t_internal*)LZ4_dict;
- int result = LZ4_compress_generic(LZ4_dict, source, dest, inputSize, 0, notLimited, byU32, usingExtDict);
+ const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize;
- streamPtr->dictionary = (const BYTE*)source;
- streamPtr->dictSize = (U32)inputSize;
- streamPtr->currentOffset += (U32)inputSize;
- /*
- streamPtr->dictSize += (U32)inputSize;
- streamPtr->currentOffset += (U32)inputSize;
- */
- return result;
+ if (dictEnd == (const BYTE*)source)
+ {
+ int result = LZ4_compress_generic(LZ4_dict, source, dest, inputSize, 0, notLimited, byU32, withPrefix64k);
+ streamPtr->dictSize += (U32)inputSize;
+ streamPtr->currentOffset += (U32)inputSize;
+ return result;
+ }
+
+ {
+ int result = LZ4_compress_generic(LZ4_dict, source, dest, inputSize, 0, notLimited, byU32, usingExtDict);
+ streamPtr->dictionary = (const BYTE*)source;
+ streamPtr->dictSize = (U32)inputSize;
+ streamPtr->currentOffset += (U32)inputSize;
+ return result;
+ }
}
int LZ4_compress_limitedOutput_usingDict (LZ4_dict_t* LZ4_dict, const char* source, char* dest, int inputSize, int maxOutputSize)
{
LZ4_dict_t_internal* streamPtr = (LZ4_dict_t_internal*)LZ4_dict;
- int result = LZ4_compress_generic(LZ4_dict, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, usingExtDict);
+ const BYTE* const dictEnd = streamPtr->dictionary + streamPtr->dictSize;
- streamPtr->dictionary = (const BYTE*)source;
- streamPtr->dictSize = (U32)inputSize;
- streamPtr->currentOffset += (U32)inputSize;
- /*
- streamPtr->dictSize += (U32)inputSize;
- streamPtr->currentOffset += (U32)inputSize;
- */
- return result;
+ if (dictEnd == (const BYTE*)source)
+ {
+ int result = LZ4_compress_generic(LZ4_dict, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, withPrefix64k);
+ streamPtr->dictSize += (U32)inputSize;
+ streamPtr->currentOffset += (U32)inputSize;
+ return result;
+ }
+
+ {
+ int result = LZ4_compress_generic(LZ4_dict, source, dest, inputSize, maxOutputSize, limitedOutput, byU32, usingExtDict);
+ streamPtr->dictionary = (const BYTE*)source;
+ streamPtr->dictSize = (U32)inputSize;
+ streamPtr->currentOffset += (U32)inputSize;
+ return result;
+ }
}
+
// Hidden debug function, to force separate dictionary mode
int LZ4_compress_forceExtDict (LZ4_dict_t* LZ4_dict, const char* source, char* dest, int inputSize)
{