extlz4 0.2.4.2 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY.ja.md +25 -0
  3. data/README.md +49 -41
  4. data/bin/extlz4 +1 -1
  5. data/contrib/lz4/INSTALL +1 -0
  6. data/contrib/lz4/Makefile.inc +87 -0
  7. data/contrib/lz4/NEWS +89 -0
  8. data/contrib/lz4/README.md +42 -36
  9. data/contrib/lz4/build/README.md +55 -0
  10. data/contrib/lz4/build/VS2010/datagen/datagen.vcxproj +169 -0
  11. data/contrib/lz4/build/VS2010/frametest/frametest.vcxproj +176 -0
  12. data/contrib/lz4/build/VS2010/fullbench-dll/fullbench-dll.vcxproj +180 -0
  13. data/contrib/lz4/build/VS2010/fullbench/fullbench.vcxproj +176 -0
  14. data/contrib/lz4/build/VS2010/fuzzer/fuzzer.vcxproj +173 -0
  15. data/contrib/lz4/build/VS2010/liblz4-dll/liblz4-dll.rc +51 -0
  16. data/contrib/lz4/build/VS2010/liblz4-dll/liblz4-dll.vcxproj +179 -0
  17. data/contrib/lz4/build/VS2010/liblz4/liblz4.vcxproj +175 -0
  18. data/contrib/lz4/build/VS2010/lz4.sln +98 -0
  19. data/contrib/lz4/build/VS2010/lz4/lz4.rc +51 -0
  20. data/contrib/lz4/build/VS2010/lz4/lz4.vcxproj +189 -0
  21. data/contrib/lz4/build/VS2017/datagen/datagen.vcxproj +173 -0
  22. data/contrib/lz4/build/VS2017/frametest/frametest.vcxproj +180 -0
  23. data/contrib/lz4/build/VS2017/fullbench-dll/fullbench-dll.vcxproj +184 -0
  24. data/contrib/lz4/build/VS2017/fullbench/fullbench.vcxproj +180 -0
  25. data/contrib/lz4/build/VS2017/fuzzer/fuzzer.vcxproj +177 -0
  26. data/contrib/lz4/build/VS2017/liblz4-dll/liblz4-dll.rc +51 -0
  27. data/contrib/lz4/build/VS2017/liblz4-dll/liblz4-dll.vcxproj +183 -0
  28. data/contrib/lz4/build/VS2017/liblz4/liblz4.vcxproj +179 -0
  29. data/contrib/lz4/build/VS2017/lz4.sln +103 -0
  30. data/contrib/lz4/build/VS2017/lz4/lz4.rc +51 -0
  31. data/contrib/lz4/build/VS2017/lz4/lz4.vcxproj +164 -0
  32. data/contrib/lz4/build/cmake/CMakeLists.txt +235 -0
  33. data/contrib/lz4/lib/README.md +98 -34
  34. data/contrib/lz4/lib/liblz4-dll.rc.in +35 -0
  35. data/contrib/lz4/lib/lz4.c +1698 -681
  36. data/contrib/lz4/lib/lz4.h +546 -235
  37. data/contrib/lz4/lib/lz4frame.c +608 -378
  38. data/contrib/lz4/lib/lz4frame.h +315 -83
  39. data/contrib/lz4/lib/lz4frame_static.h +4 -100
  40. data/contrib/lz4/lib/lz4hc.c +1090 -282
  41. data/contrib/lz4/lib/lz4hc.h +276 -141
  42. data/contrib/lz4/lib/xxhash.c +371 -235
  43. data/contrib/lz4/lib/xxhash.h +128 -93
  44. data/contrib/lz4/ossfuzz/Makefile +78 -0
  45. data/contrib/lz4/ossfuzz/compress_frame_fuzzer.c +48 -0
  46. data/contrib/lz4/ossfuzz/compress_fuzzer.c +58 -0
  47. data/contrib/lz4/ossfuzz/compress_hc_fuzzer.c +64 -0
  48. data/contrib/lz4/ossfuzz/decompress_frame_fuzzer.c +75 -0
  49. data/contrib/lz4/ossfuzz/decompress_fuzzer.c +62 -0
  50. data/contrib/lz4/ossfuzz/fuzz.h +48 -0
  51. data/contrib/lz4/ossfuzz/fuzz_data_producer.c +77 -0
  52. data/contrib/lz4/ossfuzz/fuzz_data_producer.h +36 -0
  53. data/contrib/lz4/ossfuzz/fuzz_helpers.h +94 -0
  54. data/contrib/lz4/ossfuzz/lz4_helpers.c +51 -0
  55. data/contrib/lz4/ossfuzz/lz4_helpers.h +13 -0
  56. data/contrib/lz4/ossfuzz/ossfuzz.sh +23 -0
  57. data/contrib/lz4/ossfuzz/round_trip_frame_fuzzer.c +43 -0
  58. data/contrib/lz4/ossfuzz/round_trip_fuzzer.c +57 -0
  59. data/contrib/lz4/ossfuzz/round_trip_hc_fuzzer.c +44 -0
  60. data/contrib/lz4/ossfuzz/round_trip_stream_fuzzer.c +302 -0
  61. data/contrib/lz4/ossfuzz/standaloneengine.c +74 -0
  62. data/contrib/lz4/ossfuzz/travisoss.sh +26 -0
  63. data/contrib/lz4/tmp +0 -0
  64. data/contrib/lz4/tmpsparse +0 -0
  65. data/ext/blockapi.c +5 -5
  66. data/ext/extlz4.c +2 -0
  67. data/ext/extlz4.h +5 -0
  68. data/ext/frameapi.c +1 -1
  69. data/ext/hashargs.c +2 -2
  70. data/ext/hashargs.h +1 -1
  71. data/ext/lz4_amalgam.c +0 -23
  72. data/gemstub.rb +5 -16
  73. data/lib/extlz4.rb +51 -3
  74. data/lib/extlz4/oldstream.rb +1 -1
  75. data/test/common.rb +2 -2
  76. metadata +73 -16
  77. data/contrib/lz4/circle.yml +0 -39
  78. data/contrib/lz4/lib/lz4opt.h +0 -366
  79. data/lib/extlz4/version.rb +0 -3
@@ -39,14 +39,14 @@ extern "C" {
39
39
  #endif
40
40
 
41
41
  /* --- Dependency --- */
42
- /* note : lz4hc is not an independent module, it requires lz4.h/lz4.c for proper compilation */
42
+ /* note : lz4hc requires lz4.h/lz4.c for compilation */
43
43
  #include "lz4.h" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */
44
44
 
45
45
 
46
46
  /* --- Useful constants --- */
47
47
  #define LZ4HC_CLEVEL_MIN 3
48
48
  #define LZ4HC_CLEVEL_DEFAULT 9
49
- #define LZ4HC_CLEVEL_OPT_MIN 11
49
+ #define LZ4HC_CLEVEL_OPT_MIN 10
50
50
  #define LZ4HC_CLEVEL_MAX 12
51
51
 
52
52
 
@@ -54,12 +54,12 @@ extern "C" {
54
54
  * Block Compression
55
55
  **************************************/
56
56
  /*! LZ4_compress_HC() :
57
- * Compress data from `src` into `dst`, using the more powerful but slower "HC" algorithm.
57
+ * Compress data from `src` into `dst`, using the powerful but slower "HC" algorithm.
58
58
  * `dst` must be already allocated.
59
- * Compression is guaranteed to succeed if `dstCapacity >= LZ4_compressBound(srcSize)` (see "lz4.h")
60
- * Max supported `srcSize` value is LZ4_MAX_INPUT_SIZE (see "lz4.h")
61
- * `compressionLevel` : Recommended values are between 4 and 9, although any value between 1 and LZ4HC_CLEVEL_MAX will work.
62
- * Values >LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX.
59
+ * Compression is guaranteed to succeed if `dstCapacity >= LZ4_compressBound(srcSize)` (see "lz4.h")
60
+ * Max supported `srcSize` value is LZ4_MAX_INPUT_SIZE (see "lz4.h")
61
+ * `compressionLevel` : any value between 1 and LZ4HC_CLEVEL_MAX will work.
62
+ * Values > LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX.
63
63
  * @return : the number of bytes written into 'dst'
64
64
  * or 0 if compression fails.
65
65
  */
@@ -72,12 +72,26 @@ LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int dst
72
72
 
73
73
 
74
74
  /*! LZ4_compress_HC_extStateHC() :
75
- * Same as LZ4_compress_HC(), but using an externally allocated memory segment for `state`.
75
+ * Same as LZ4_compress_HC(), but using an externally allocated memory segment for `state`.
76
76
  * `state` size is provided by LZ4_sizeofStateHC().
77
- * Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() will do properly).
77
+ * Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).
78
78
  */
79
- LZ4LIB_API int LZ4_compress_HC_extStateHC(void* state, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
80
79
  LZ4LIB_API int LZ4_sizeofStateHC(void);
80
+ LZ4LIB_API int LZ4_compress_HC_extStateHC(void* stateHC, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
81
+
82
+
83
+ /*! LZ4_compress_HC_destSize() : v1.9.0+
84
+ * Will compress as much data as possible from `src`
85
+ * to fit into `targetDstSize` budget.
86
+ * Result is provided in 2 parts :
87
+ * @return : the number of bytes written into 'dst' (necessarily <= targetDstSize)
88
+ * or 0 if compression fails.
89
+ * `srcSizePtr` : on success, *srcSizePtr is updated to indicate how much bytes were read from `src`
90
+ */
91
+ LZ4LIB_API int LZ4_compress_HC_destSize(void* stateHC,
92
+ const char* src, char* dst,
93
+ int* srcSizePtr, int targetDstSize,
94
+ int compressionLevel);
81
95
 
82
96
 
83
97
  /*-************************************
@@ -87,49 +101,95 @@ LZ4LIB_API int LZ4_sizeofStateHC(void);
87
101
  typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */
88
102
 
89
103
  /*! LZ4_createStreamHC() and LZ4_freeStreamHC() :
90
- * These functions create and release memory for LZ4 HC streaming state.
91
- * Newly created states are automatically initialized.
92
- * Existing states can be re-used several times, using LZ4_resetStreamHC().
93
- * These methods are API and ABI stable, they can be used in combination with a DLL.
104
+ * These functions create and release memory for LZ4 HC streaming state.
105
+ * Newly created states are automatically initialized.
106
+ * A same state can be used multiple times consecutively,
107
+ * starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.
94
108
  */
95
109
  LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC(void);
96
110
  LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr);
97
111
 
98
- LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
99
- LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
100
-
101
- LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, const char* src, char* dst, int srcSize, int maxDstSize);
102
-
103
- LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
104
-
105
112
  /*
106
- These functions compress data in successive blocks of any size, using previous blocks as dictionary.
113
+ These functions compress data in successive blocks of any size,
114
+ using previous blocks as dictionary, to improve compression ratio.
107
115
  One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks.
108
116
  There is an exception for ring buffers, which can be smaller than 64 KB.
109
- Ring buffers scenario is automatically detected and handled by LZ4_compress_HC_continue().
117
+ Ring-buffer scenario is automatically detected and handled within LZ4_compress_HC_continue().
118
+
119
+ Before starting compression, state must be allocated and properly initialized.
120
+ LZ4_createStreamHC() does both, though compression level is set to LZ4HC_CLEVEL_DEFAULT.
121
+
122
+ Selecting the compression level can be done with LZ4_resetStreamHC_fast() (starts a new stream)
123
+ or LZ4_setCompressionLevel() (anytime, between blocks in the same stream) (experimental).
124
+ LZ4_resetStreamHC_fast() only works on states which have been properly initialized at least once,
125
+ which is automatically the case when state is created using LZ4_createStreamHC().
126
+
127
+ After reset, a first "fictional block" can be designated as initial dictionary,
128
+ using LZ4_loadDictHC() (Optional).
129
+
130
+ Invoke LZ4_compress_HC_continue() to compress each successive block.
131
+ The number of blocks is unlimited.
132
+ Previous input blocks, including initial dictionary when present,
133
+ must remain accessible and unmodified during compression.
134
+
135
+ It's allowed to update compression level anytime between blocks,
136
+ using LZ4_setCompressionLevel() (experimental).
137
+
138
+ 'dst' buffer should be sized to handle worst case scenarios
139
+ (see LZ4_compressBound(), it ensures compression success).
140
+ In case of failure, the API does not guarantee recovery,
141
+ so the state _must_ be reset.
142
+ To ensure compression success
143
+ whenever `dst` buffer size cannot be made >= LZ4_compressBound(),
144
+ consider using LZ4_compress_HC_continue_destSize().
145
+
146
+ Whenever previous input blocks can't be preserved unmodified in-place during compression of next blocks,
147
+ it's possible to copy the last blocks into a more stable memory space, using LZ4_saveDictHC().
148
+ Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer' (<= 64 KB)
149
+
150
+ After completing a streaming compression,
151
+ it's possible to start a new stream of blocks, using the same LZ4_streamHC_t state,
152
+ just by resetting it, using LZ4_resetStreamHC_fast().
153
+ */
110
154
 
111
- Before starting compression, state must be properly initialized, using LZ4_resetStreamHC().
112
- A first "fictional block" can then be designated as initial dictionary, using LZ4_loadDictHC() (Optional).
155
+ LZ4LIB_API void LZ4_resetStreamHC_fast(LZ4_streamHC_t* streamHCPtr, int compressionLevel); /* v1.9.0+ */
156
+ LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
157
+
158
+ LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr,
159
+ const char* src, char* dst,
160
+ int srcSize, int maxDstSize);
161
+
162
+ /*! LZ4_compress_HC_continue_destSize() : v1.9.0+
163
+ * Similar to LZ4_compress_HC_continue(),
164
+ * but will read as much data as possible from `src`
165
+ * to fit into `targetDstSize` budget.
166
+ * Result is provided into 2 parts :
167
+ * @return : the number of bytes written into 'dst' (necessarily <= targetDstSize)
168
+ * or 0 if compression fails.
169
+ * `srcSizePtr` : on success, *srcSizePtr will be updated to indicate how much bytes were read from `src`.
170
+ * Note that this function may not consume the entire input.
171
+ */
172
+ LZ4LIB_API int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t* LZ4_streamHCPtr,
173
+ const char* src, char* dst,
174
+ int* srcSizePtr, int targetDstSize);
175
+
176
+ LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
113
177
 
114
- Then, use LZ4_compress_HC_continue() to compress each successive block.
115
- Previous memory blocks (including initial dictionary when present) must remain accessible and unmodified during compression.
116
- 'dst' buffer should be sized to handle worst case scenarios (see LZ4_compressBound()), to ensure operation success.
117
- Because in case of failure, the API does not guarantee context recovery, and context will have to be reset.
118
- If `dst` buffer budget cannot be >= LZ4_compressBound(), consider using LZ4_compress_HC_continue_destSize() instead.
119
178
 
120
- If, for any reason, previous data block can't be preserved unmodified in memory for next compression block,
121
- you can save it to a more stable memory space, using LZ4_saveDictHC().
122
- Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer'.
123
- */
124
179
 
180
+ /*^**********************************************
181
+ * !!!!!! STATIC LINKING ONLY !!!!!!
182
+ ***********************************************/
125
183
 
126
- /*-*************************************
184
+ /*-******************************************************************
127
185
  * PRIVATE DEFINITIONS :
128
- * Do not use these definitions.
129
- * They are exposed to allow static allocation of `LZ4_streamHC_t`.
130
- * Using these definitions makes the code vulnerable to potential API break when upgrading LZ4
131
- **************************************/
132
- #define LZ4HC_DICTIONARY_LOGSIZE 17 /* because of btopt, hc would only need 16 */
186
+ * Do not use these definitions directly.
187
+ * They are merely exposed to allow static allocation of `LZ4_streamHC_t`.
188
+ * Declare an `LZ4_streamHC_t` directly, rather than any type below.
189
+ * Even then, only do so in the context of static linking, as definitions may change between versions.
190
+ ********************************************************************/
191
+
192
+ #define LZ4HC_DICTIONARY_LOGSIZE 16
133
193
  #define LZ4HC_MAXD (1<<LZ4HC_DICTIONARY_LOGSIZE)
134
194
  #define LZ4HC_MAXD_MASK (LZ4HC_MAXD - 1)
135
195
 
@@ -138,57 +198,53 @@ LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, in
138
198
  #define LZ4HC_HASH_MASK (LZ4HC_HASHTABLESIZE - 1)
139
199
 
140
200
 
141
- #if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
142
- #include <stdint.h>
143
-
144
- typedef struct
145
- {
146
- uint32_t hashTable[LZ4HC_HASHTABLESIZE];
147
- uint16_t chainTable[LZ4HC_MAXD];
148
- const uint8_t* end; /* next block here to continue on current prefix */
149
- const uint8_t* base; /* All index relative to this position */
150
- const uint8_t* dictBase; /* alternate base for extDict */
151
- uint8_t* inputBuffer; /* deprecated */
152
- uint32_t dictLimit; /* below that point, need extDict */
153
- uint32_t lowLimit; /* below that point, no more dict */
154
- uint32_t nextToUpdate; /* index from which to continue dictionary update */
155
- uint32_t searchNum; /* only for optimal parser */
156
- uint32_t compressionLevel;
157
- } LZ4HC_CCtx_internal;
158
-
159
- #else
160
-
161
- typedef struct
201
+ typedef struct LZ4HC_CCtx_internal LZ4HC_CCtx_internal;
202
+ struct LZ4HC_CCtx_internal
162
203
  {
163
- unsigned int hashTable[LZ4HC_HASHTABLESIZE];
164
- unsigned short chainTable[LZ4HC_MAXD];
165
- const unsigned char* end; /* next block here to continue on current prefix */
166
- const unsigned char* base; /* All index relative to this position */
167
- const unsigned char* dictBase; /* alternate base for extDict */
168
- unsigned char* inputBuffer; /* deprecated */
169
- unsigned int dictLimit; /* below that point, need extDict */
170
- unsigned int lowLimit; /* below that point, no more dict */
171
- unsigned int nextToUpdate; /* index from which to continue dictionary update */
172
- unsigned int searchNum; /* only for optimal parser */
173
- int compressionLevel;
174
- } LZ4HC_CCtx_internal;
175
-
176
- #endif
177
-
178
- #define LZ4_STREAMHCSIZE (4*LZ4HC_HASHTABLESIZE + 2*LZ4HC_MAXD + 56) /* 393268 */
179
- #define LZ4_STREAMHCSIZE_SIZET (LZ4_STREAMHCSIZE / sizeof(size_t))
204
+ LZ4_u32 hashTable[LZ4HC_HASHTABLESIZE];
205
+ LZ4_u16 chainTable[LZ4HC_MAXD];
206
+ const LZ4_byte* end; /* next block here to continue on current prefix */
207
+ const LZ4_byte* base; /* All index relative to this position */
208
+ const LZ4_byte* dictBase; /* alternate base for extDict */
209
+ LZ4_u32 dictLimit; /* below that point, need extDict */
210
+ LZ4_u32 lowLimit; /* below that point, no more dict */
211
+ LZ4_u32 nextToUpdate; /* index from which to continue dictionary update */
212
+ short compressionLevel;
213
+ LZ4_i8 favorDecSpeed; /* favor decompression speed if this flag set,
214
+ otherwise, favor compression ratio */
215
+ LZ4_i8 dirty; /* stream has to be fully reset if this flag is set */
216
+ const LZ4HC_CCtx_internal* dictCtx;
217
+ };
218
+
219
+
220
+ /* Do not use these definitions directly !
221
+ * Declare or allocate an LZ4_streamHC_t instead.
222
+ */
223
+ #define LZ4_STREAMHCSIZE 262200 /* static size, for inter-version compatibility */
224
+ #define LZ4_STREAMHCSIZE_VOIDP (LZ4_STREAMHCSIZE / sizeof(void*))
180
225
  union LZ4_streamHC_u {
181
- size_t table[LZ4_STREAMHCSIZE_SIZET];
226
+ void* table[LZ4_STREAMHCSIZE_VOIDP];
182
227
  LZ4HC_CCtx_internal internal_donotuse;
183
- }; /* previously typedef'd to LZ4_streamHC_t */
184
- /*
185
- LZ4_streamHC_t :
186
- This structure allows static allocation of LZ4 HC streaming state.
187
- State must be initialized using LZ4_resetStreamHC() before first use.
228
+ }; /* previously typedef'd to LZ4_streamHC_t */
229
+
230
+ /* LZ4_streamHC_t :
231
+ * This structure allows static allocation of LZ4 HC streaming state.
232
+ * This can be used to allocate statically, on state, or as part of a larger structure.
233
+ *
234
+ * Such state **must** be initialized using LZ4_initStreamHC() before first use.
235
+ *
236
+ * Note that invoking LZ4_initStreamHC() is not required when
237
+ * the state was created using LZ4_createStreamHC() (which is recommended).
238
+ * Using the normal builder, a newly created state is automatically initialized.
239
+ *
240
+ * Static allocation shall only be used in combination with static linking.
241
+ */
188
242
 
189
- Static allocation shall only be used in combination with static linking.
190
- When invoking LZ4 from a DLL, use create/free functions instead, which are API and ABI stable.
191
- */
243
+ /* LZ4_initStreamHC() : v1.9.0+
244
+ * Required before first use of a statically allocated LZ4_streamHC_t.
245
+ * Before v1.9.0 : use LZ4_resetStreamHC() instead
246
+ */
247
+ LZ4LIB_API LZ4_streamHC_t* LZ4_initStreamHC (void* buffer, size_t size);
192
248
 
193
249
 
194
250
  /*-************************************
@@ -197,26 +253,43 @@ union LZ4_streamHC_u {
197
253
  /* see lz4.h LZ4_DISABLE_DEPRECATE_WARNINGS to turn off deprecation warnings */
198
254
 
199
255
  /* deprecated compression functions */
200
- /* these functions will trigger warning messages in future releases */
201
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC (const char* source, char* dest, int inputSize);
202
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
203
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
204
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC() instead") int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
205
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
206
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
207
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
208
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
209
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
210
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
211
-
212
- /* Deprecated Streaming functions using older model; should no longer be used */
213
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_createStreamHC() instead") void* LZ4_createHC (char* inputBuffer);
214
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_saveDictHC() instead") char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
215
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") int LZ4_freeHC (void* LZ4HC_Data);
216
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
217
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
218
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_createStreamHC() instead") int LZ4_sizeofStreamStateHC(void);
219
- LZ4LIB_API LZ4_DEPRECATED("use LZ4_resetStreamHC() instead") int LZ4_resetStreamStateHC(void* state, char* inputBuffer);
256
+ LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC (const char* source, char* dest, int inputSize);
257
+ LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
258
+ LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
259
+ LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
260
+ LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
261
+ LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
262
+ LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
263
+ LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
264
+ LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
265
+ LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
266
+
267
+ /* Obsolete streaming functions; degraded functionality; do not use!
268
+ *
269
+ * In order to perform streaming compression, these functions depended on data
270
+ * that is no longer tracked in the state. They have been preserved as well as
271
+ * possible: using them will still produce a correct output. However, use of
272
+ * LZ4_slideInputBufferHC() will truncate the history of the stream, rather
273
+ * than preserve a window-sized chunk of history.
274
+ */
275
+ LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API void* LZ4_createHC (const char* inputBuffer);
276
+ LZ4_DEPRECATED("use LZ4_saveDictHC() instead") LZ4LIB_API char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
277
+ LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") LZ4LIB_API int LZ4_freeHC (void* LZ4HC_Data);
278
+ LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
279
+ LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
280
+ LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API int LZ4_sizeofStreamStateHC(void);
281
+ LZ4_DEPRECATED("use LZ4_initStreamHC() instead") LZ4LIB_API int LZ4_resetStreamStateHC(void* state, char* inputBuffer);
282
+
283
+
284
+ /* LZ4_resetStreamHC() is now replaced by LZ4_initStreamHC().
285
+ * The intention is to emphasize the difference with LZ4_resetStreamHC_fast(),
286
+ * which is now the recommended function to start a new stream of blocks,
287
+ * but cannot be used to initialize a memory segment containing arbitrary garbage data.
288
+ *
289
+ * It is recommended to switch to LZ4_initStreamHC().
290
+ * LZ4_resetStreamHC() will generate deprecation warnings in a future version.
291
+ */
292
+ LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
220
293
 
221
294
 
222
295
  #if defined (__cplusplus)
@@ -225,54 +298,116 @@ LZ4LIB_API LZ4_DEPRECATED("use LZ4_resetStreamHC() instead") int LZ4_resetStr
225
298
 
226
299
  #endif /* LZ4_HC_H_19834876238432 */
227
300
 
228
- /*-************************************************
301
+
302
+ /*-**************************************************
229
303
  * !!!!! STATIC LINKING ONLY !!!!!
230
304
  * Following definitions are considered experimental.
231
305
  * They should not be linked from DLL,
232
306
  * as there is no guarantee of API stability yet.
233
307
  * Prototypes will be promoted to "stable" status
234
308
  * after successfull usage in real-life scenarios.
235
- *************************************************/
309
+ ***************************************************/
236
310
  #ifdef LZ4_HC_STATIC_LINKING_ONLY /* protection macro */
237
311
  #ifndef LZ4_HC_SLO_098092834
238
312
  #define LZ4_HC_SLO_098092834
239
313
 
240
- /*! LZ4_compress_HC_destSize() : v1.8.0 (experimental)
241
- * Will try to compress as much data from `src` as possible
242
- * that can fit into `targetDstSize` budget.
243
- * Result is provided in 2 parts :
244
- * @return : the number of bytes written into 'dst'
245
- * or 0 if compression fails.
246
- * `srcSizePtr` : value will be updated to indicate how much bytes were read from `src`
314
+ #define LZ4_STATIC_LINKING_ONLY /* LZ4LIB_STATIC_API */
315
+ #include "lz4.h"
316
+
317
+ #if defined (__cplusplus)
318
+ extern "C" {
319
+ #endif
320
+
321
+ /*! LZ4_setCompressionLevel() : v1.8.0+ (experimental)
322
+ * It's possible to change compression level
323
+ * between successive invocations of LZ4_compress_HC_continue*()
324
+ * for dynamic adaptation.
247
325
  */
248
- int LZ4_compress_HC_destSize(void* LZ4HC_Data,
249
- const char* src, char* dst,
250
- int* srcSizePtr, int targetDstSize,
251
- int compressionLevel);
252
-
253
- /*! LZ4_compress_HC_continue_destSize() : v1.8.0 (experimental)
254
- * Similar as LZ4_compress_HC_continue(),
255
- * but will read a variable nb of bytes from `src`
256
- * to fit into `targetDstSize` budget.
257
- * Result is provided in 2 parts :
258
- * @return : the number of bytes written into 'dst'
259
- * or 0 if compression fails.
260
- * `srcSizePtr` : value will be updated to indicate how much bytes were read from `src`.
261
- * Important : due to limitations, this prototype only works well up to cLevel < LZ4HC_CLEVEL_OPT_MIN
262
- * beyond that level, compression performance will be much reduced due to internal incompatibilities
326
+ LZ4LIB_STATIC_API void LZ4_setCompressionLevel(
327
+ LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
328
+
329
+ /*! LZ4_favorDecompressionSpeed() : v1.8.2+ (experimental)
330
+ * Opt. Parser will favor decompression speed over compression ratio.
331
+ * Only applicable to levels >= LZ4HC_CLEVEL_OPT_MIN.
263
332
  */
264
- int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t* LZ4_streamHCPtr,
265
- const char* src, char* dst,
266
- int* srcSizePtr, int targetDstSize);
267
-
268
- /*! LZ4_setCompressionLevel() : v1.8.0 (experimental)
269
- * It's possible to change compression level after LZ4_resetStreamHC(), between 2 invocations of LZ4_compress_HC_continue*(),
270
- * but that requires to stay in the same mode (aka 1-10 or 11-12).
271
- * This function ensures this condition.
333
+ LZ4LIB_STATIC_API void LZ4_favorDecompressionSpeed(
334
+ LZ4_streamHC_t* LZ4_streamHCPtr, int favor);
335
+
336
+ /*! LZ4_resetStreamHC_fast() : v1.9.0+
337
+ * When an LZ4_streamHC_t is known to be in a internally coherent state,
338
+ * it can often be prepared for a new compression with almost no work, only
339
+ * sometimes falling back to the full, expensive reset that is always required
340
+ * when the stream is in an indeterminate state (i.e., the reset performed by
341
+ * LZ4_resetStreamHC()).
342
+ *
343
+ * LZ4_streamHCs are guaranteed to be in a valid state when:
344
+ * - returned from LZ4_createStreamHC()
345
+ * - reset by LZ4_resetStreamHC()
346
+ * - memset(stream, 0, sizeof(LZ4_streamHC_t))
347
+ * - the stream was in a valid state and was reset by LZ4_resetStreamHC_fast()
348
+ * - the stream was in a valid state and was then used in any compression call
349
+ * that returned success
350
+ * - the stream was in an indeterminate state and was used in a compression
351
+ * call that fully reset the state (LZ4_compress_HC_extStateHC()) and that
352
+ * returned success
353
+ *
354
+ * Note:
355
+ * A stream that was last used in a compression call that returned an error
356
+ * may be passed to this function. However, it will be fully reset, which will
357
+ * clear any existing history and settings from the context.
272
358
  */
273
- void LZ4_setCompressionLevel(LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
274
-
359
+ LZ4LIB_STATIC_API void LZ4_resetStreamHC_fast(
360
+ LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
361
+
362
+ /*! LZ4_compress_HC_extStateHC_fastReset() :
363
+ * A variant of LZ4_compress_HC_extStateHC().
364
+ *
365
+ * Using this variant avoids an expensive initialization step. It is only safe
366
+ * to call if the state buffer is known to be correctly initialized already
367
+ * (see above comment on LZ4_resetStreamHC_fast() for a definition of
368
+ * "correctly initialized"). From a high level, the difference is that this
369
+ * function initializes the provided state with a call to
370
+ * LZ4_resetStreamHC_fast() while LZ4_compress_HC_extStateHC() starts with a
371
+ * call to LZ4_resetStreamHC().
372
+ */
373
+ LZ4LIB_STATIC_API int LZ4_compress_HC_extStateHC_fastReset (
374
+ void* state,
375
+ const char* src, char* dst,
376
+ int srcSize, int dstCapacity,
377
+ int compressionLevel);
378
+
379
+ /*! LZ4_attach_HC_dictionary() :
380
+ * This is an experimental API that allows for the efficient use of a
381
+ * static dictionary many times.
382
+ *
383
+ * Rather than re-loading the dictionary buffer into a working context before
384
+ * each compression, or copying a pre-loaded dictionary's LZ4_streamHC_t into a
385
+ * working LZ4_streamHC_t, this function introduces a no-copy setup mechanism,
386
+ * in which the working stream references the dictionary stream in-place.
387
+ *
388
+ * Several assumptions are made about the state of the dictionary stream.
389
+ * Currently, only streams which have been prepared by LZ4_loadDictHC() should
390
+ * be expected to work.
391
+ *
392
+ * Alternatively, the provided dictionary stream pointer may be NULL, in which
393
+ * case any existing dictionary stream is unset.
394
+ *
395
+ * A dictionary should only be attached to a stream without any history (i.e.,
396
+ * a stream that has just been reset).
397
+ *
398
+ * The dictionary will remain attached to the working stream only for the
399
+ * current stream session. Calls to LZ4_resetStreamHC(_fast) will remove the
400
+ * dictionary context association from the working stream. The dictionary
401
+ * stream (and source buffer) must remain in-place / accessible / unchanged
402
+ * through the lifetime of the stream session.
403
+ */
404
+ LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary(
405
+ LZ4_streamHC_t *working_stream,
406
+ const LZ4_streamHC_t *dictionary_stream);
275
407
 
408
+ #if defined (__cplusplus)
409
+ }
410
+ #endif
276
411
 
277
412
  #endif /* LZ4_HC_SLO_098092834 */
278
413
  #endif /* LZ4_HC_STATIC_LINKING_ONLY */