diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2014-06-02 07:13:16 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2014-06-02 07:13:16 (GMT) |
commit | ec717699c7841b4471ee6566d80f4835ace8438b (patch) | |
tree | a97733056007e54243899d68ab2c496e50cfb552 /lz4.c | |
parent | b636779b0e168c346b42e85af816ce37a8ed9880 (diff) | |
download | lz4-ec717699c7841b4471ee6566d80f4835ace8438b.zip lz4-ec717699c7841b4471ee6566d80f4835ace8438b.tar.gz lz4-ec717699c7841b4471ee6566d80f4835ace8438b.tar.bz2 |
restored continuous streaming mode
Diffstat (limited to 'lz4.c')
-rwxr-xr-x | lz4.c | 51 |
1 files changed, 33 insertions, 18 deletions
@@ -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) { |