• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>1.9.2 Manual</title>
5</head>
6<body>
7<h1>1.9.2 Manual</h1>
8<hr>
9<a name="Contents"></a><h2>Contents</h2>
10<ol>
11<li><a href="#Chapter1">Introduction</a></li>
12<li><a href="#Chapter2">Version</a></li>
13<li><a href="#Chapter3">Tuning parameter</a></li>
14<li><a href="#Chapter4">Simple Functions</a></li>
15<li><a href="#Chapter5">Advanced Functions</a></li>
16<li><a href="#Chapter6">Streaming Compression Functions</a></li>
17<li><a href="#Chapter7">Streaming Decompression Functions</a></li>
18<li><a href="#Chapter8">Experimental section</a></li>
19<li><a href="#Chapter9">PRIVATE DEFINITIONS</a></li>
20<li><a href="#Chapter10">Obsolete Functions</a></li>
21</ol>
22<hr>
23<a name="Chapter1"></a><h2>Introduction</h2><pre>
24  LZ4 is lossless compression algorithm, providing compression speed >500 MB/s per core,
25  scalable with multi-cores CPU. It features an extremely fast decoder, with speed in
26  multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.
27
28  The LZ4 compression library provides in-memory compression and decompression functions.
29  It gives full buffer control to user.
30  Compression can be done in:
31    - a single step (described as Simple Functions)
32    - a single step, reusing a context (described in Advanced Functions)
33    - unbounded multiple steps (described as Streaming compression)
34
35  lz4.h generates and decodes LZ4-compressed blocks (doc/lz4_Block_format.md).
36  Decompressing such a compressed block requires additional metadata.
37  Exact metadata depends on exact decompression function.
38  For the typical case of LZ4_decompress_safe(),
39  metadata includes block's compressed size, and maximum bound of decompressed size.
40  Each application is free to encode and pass such metadata in whichever way it wants.
41
42  lz4.h only handle blocks, it can not generate Frames.
43
44  Blocks are different from Frames (doc/lz4_Frame_format.md).
45  Frames bundle both blocks and metadata in a specified manner.
46  Embedding metadata is required for compressed data to be self-contained and portable.
47  Frame format is delivered through a companion API, declared in lz4frame.h.
48  The `lz4` CLI can only manage frames.
49<BR></pre>
50
51<a name="Chapter2"></a><h2>Version</h2><pre></pre>
52
53<pre><b>int LZ4_versionNumber (void);  </b>/**< library version number; useful to check dll version */<b>
54</b></pre><BR>
55<pre><b>const char* LZ4_versionString (void);   </b>/**< library version string; useful to check dll version */<b>
56</b></pre><BR>
57<a name="Chapter3"></a><h2>Tuning parameter</h2><pre></pre>
58
59<pre><b>#ifndef LZ4_MEMORY_USAGE
60# define LZ4_MEMORY_USAGE 14
61#endif
62</b><p> Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.)
63 Increasing memory usage improves compression ratio.
64 Reduced memory usage may improve speed, thanks to better cache locality.
65 Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
66
67</p></pre><BR>
68
69<a name="Chapter4"></a><h2>Simple Functions</h2><pre></pre>
70
71<pre><b>int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
72</b><p>  Compresses 'srcSize' bytes from buffer 'src'
73  into already allocated 'dst' buffer of size 'dstCapacity'.
74  Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize).
75  It also runs faster, so it's a recommended setting.
76  If the function cannot compress 'src' into a more limited 'dst' budget,
77  compression stops *immediately*, and the function result is zero.
78  In which case, 'dst' content is undefined (invalid).
79      srcSize : max supported value is LZ4_MAX_INPUT_SIZE.
80      dstCapacity : size of buffer 'dst' (which must be already allocated)
81     @return  : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity)
82                or 0 if compression fails
83 Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).
84
85</p></pre><BR>
86
87<pre><b>int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity);
88</b><p>  compressedSize : is the exact complete size of the compressed block.
89  dstCapacity : is the size of destination buffer (which must be already allocated), presumed an upper bound of decompressed size.
90 @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
91           If destination buffer is not large enough, decoding will stop and output an error code (negative value).
92           If the source stream is detected malformed, the function will stop decoding and return a negative result.
93 Note 1 : This function is protected against malicious data packets :
94          it will never writes outside 'dst' buffer, nor read outside 'source' buffer,
95          even if the compressed block is maliciously modified to order the decoder to do these actions.
96          In such case, the decoder stops immediately, and considers the compressed block malformed.
97 Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them.
98          The implementation is free to send / store / derive this information in whichever way is most beneficial.
99          If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead.
100
101</p></pre><BR>
102
103<a name="Chapter5"></a><h2>Advanced Functions</h2><pre></pre>
104
105<pre><b>int LZ4_compressBound(int inputSize);
106</b><p>    Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
107    This function is primarily useful for memory allocation purposes (destination buffer size).
108    Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).
109    Note that LZ4_compress_default() compresses faster when dstCapacity is >= LZ4_compressBound(srcSize)
110        inputSize  : max supported value is LZ4_MAX_INPUT_SIZE
111        return : maximum output size in a "worst case" scenario
112              or 0, if input size is incorrect (too large or negative)
113</p></pre><BR>
114
115<pre><b>int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
116</b><p>    Same as LZ4_compress_default(), but allows selection of "acceleration" factor.
117    The larger the acceleration value, the faster the algorithm, but also the lesser the compression.
118    It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.
119    An acceleration value of "1" is the same as regular LZ4_compress_default()
120    Values <= 0 will be replaced by ACCELERATION_DEFAULT (currently == 1, see lz4.c).
121</p></pre><BR>
122
123<pre><b>int LZ4_sizeofState(void);
124int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
125</b><p>  Same as LZ4_compress_fast(), using an externally allocated memory space for its state.
126  Use LZ4_sizeofState() to know how much memory must be allocated,
127  and allocate it on 8-bytes boundaries (using `malloc()` typically).
128  Then, provide this buffer as `void* state` to compression function.
129
130</p></pre><BR>
131
132<pre><b>int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
133</b><p>  Reverse the logic : compresses as much data as possible from 'src' buffer
134  into already allocated buffer 'dst', of size >= 'targetDestSize'.
135  This function either compresses the entire 'src' content into 'dst' if it's large enough,
136  or fill 'dst' buffer completely with as much data as possible from 'src'.
137  note: acceleration parameter is fixed to "default".
138
139 *srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'.
140               New value is necessarily <= input value.
141 @return : Nb bytes written into 'dst' (necessarily <= targetDestSize)
142           or 0 if compression fails.
143</p></pre><BR>
144
145<pre><b>int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity);
146</b><p>  Decompress an LZ4 compressed block, of size 'srcSize' at position 'src',
147  into destination buffer 'dst' of size 'dstCapacity'.
148  Up to 'targetOutputSize' bytes will be decoded.
149  The function stops decoding on reaching this objective,
150  which can boost performance when only the beginning of a block is required.
151
152 @return : the number of bytes decoded in `dst` (necessarily <= dstCapacity)
153           If source stream is detected malformed, function returns a negative result.
154
155  Note : @return can be < targetOutputSize, if compressed block contains less data.
156
157  Note 2 : this function features 2 parameters, targetOutputSize and dstCapacity,
158           and expects targetOutputSize <= dstCapacity.
159           It effectively stops decoding on reaching targetOutputSize,
160           so dstCapacity is kind of redundant.
161           This is because in a previous version of this function,
162           decoding operation would not "break" a sequence in the middle.
163           As a consequence, there was no guarantee that decoding would stop at exactly targetOutputSize,
164           it could write more bytes, though only up to dstCapacity.
165           Some "margin" used to be required for this operation to work properly.
166           This is no longer necessary.
167           The function nonetheless keeps its signature, in an effort to not break API.
168
169</p></pre><BR>
170
171<a name="Chapter6"></a><h2>Streaming Compression Functions</h2><pre></pre>
172
173<pre><b>void LZ4_resetStream_fast (LZ4_stream_t* streamPtr);
174</b><p>  Use this to prepare an LZ4_stream_t for a new chain of dependent blocks
175  (e.g., LZ4_compress_fast_continue()).
176
177  An LZ4_stream_t must be initialized once before usage.
178  This is automatically done when created by LZ4_createStream().
179  However, should the LZ4_stream_t be simply declared on stack (for example),
180  it's necessary to initialize it first, using LZ4_initStream().
181
182  After init, start any new stream with LZ4_resetStream_fast().
183  A same LZ4_stream_t can be re-used multiple times consecutively
184  and compress multiple streams,
185  provided that it starts each new stream with LZ4_resetStream_fast().
186
187  LZ4_resetStream_fast() is much faster than LZ4_initStream(),
188  but is not compatible with memory regions containing garbage data.
189
190  Note: it's only useful to call LZ4_resetStream_fast()
191        in the context of streaming compression.
192        The *extState* functions perform their own resets.
193        Invoking LZ4_resetStream_fast() before is redundant, and even counterproductive.
194
195</p></pre><BR>
196
197<pre><b>int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
198</b><p>  Use this function to reference a static dictionary into LZ4_stream_t.
199  The dictionary must remain available during compression.
200  LZ4_loadDict() triggers a reset, so any previous data will be forgotten.
201  The same dictionary will have to be loaded on decompression side for successful decoding.
202  Dictionary are useful for better compression of small data (KB range).
203  While LZ4 accept any input as dictionary,
204  results are generally better when using Zstandard's Dictionary Builder.
205  Loading a size of 0 is allowed, and is the same as reset.
206 @return : loaded dictionary size, in bytes (necessarily <= 64 KB)
207
208</p></pre><BR>
209
210<pre><b>int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
211</b><p>  Compress 'src' content using data from previously compressed blocks, for better compression ratio.
212 'dst' buffer must be already allocated.
213  If dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster.
214
215 @return : size of compressed block
216           or 0 if there is an error (typically, cannot fit into 'dst').
217
218  Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new block.
219           Each block has precise boundaries.
220           Each block must be decompressed separately, calling LZ4_decompress_*() with relevant metadata.
221           It's not possible to append blocks together and expect a single invocation of LZ4_decompress_*() to decompress them together.
222
223  Note 2 : The previous 64KB of source data is __assumed__ to remain present, unmodified, at same address in memory !
224
225  Note 3 : When input is structured as a double-buffer, each buffer can have any size, including < 64 KB.
226           Make sure that buffers are separated, by at least one byte.
227           This construction ensures that each block only depends on previous block.
228
229  Note 4 : If input buffer is a ring-buffer, it can have any size, including < 64 KB.
230
231  Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed.
232
233</p></pre><BR>
234
235<pre><b>int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize);
236</b><p>  If last 64KB data cannot be guaranteed to remain available at its current memory location,
237  save it into a safer place (char* safeBuffer).
238  This is schematically equivalent to a memcpy() followed by LZ4_loadDict(),
239  but is much faster, because LZ4_saveDict() doesn't need to rebuild tables.
240 @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0 if error.
241
242</p></pre><BR>
243
244<a name="Chapter7"></a><h2>Streaming Decompression Functions</h2><pre>  Bufferless synchronous API
245<BR></pre>
246
247<pre><b>LZ4_streamDecode_t* LZ4_createStreamDecode(void);
248int                 LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
249</b><p>  creation / destruction of streaming decompression tracking context.
250  A tracking context can be re-used multiple times.
251
252</p></pre><BR>
253
254<pre><b>int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
255</b><p>  An LZ4_streamDecode_t context can be allocated once and re-used multiple times.
256  Use this function to start decompression of a new stream of blocks.
257  A dictionary can optionally be set. Use NULL or size 0 for a reset order.
258  Dictionary is presumed stable : it must remain accessible and unmodified during next decompression.
259 @return : 1 if OK, 0 if error
260
261</p></pre><BR>
262
263<pre><b>int LZ4_decoderRingBufferSize(int maxBlockSize);
264#define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) (65536 + 14 + (maxBlockSize))  </b>/* for static allocation; maxBlockSize presumed valid */<b>
265</b><p>  Note : in a ring buffer scenario (optional),
266  blocks are presumed decompressed next to each other
267  up to the moment there is not enough remaining space for next block (remainingSize < maxBlockSize),
268  at which stage it resumes from beginning of ring buffer.
269  When setting such a ring buffer for streaming decompression,
270  provides the minimum size of this ring buffer
271  to be compatible with any source respecting maxBlockSize condition.
272 @return : minimum ring buffer size,
273           or 0 if there is an error (invalid maxBlockSize).
274
275</p></pre><BR>
276
277<pre><b>int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int srcSize, int dstCapacity);
278</b><p>  These decoding functions allow decompression of consecutive blocks in "streaming" mode.
279  A block is an unsplittable entity, it must be presented entirely to a decompression function.
280  Decompression functions only accepts one block at a time.
281  The last 64KB of previously decoded data *must* remain available and unmodified at the memory position where they were decoded.
282  If less than 64KB of data has been decoded, all the data must be present.
283
284  Special : if decompression side sets a ring buffer, it must respect one of the following conditions :
285  - Decompression buffer size is _at least_ LZ4_decoderRingBufferSize(maxBlockSize).
286    maxBlockSize is the maximum size of any single block. It can have any value > 16 bytes.
287    In which case, encoding and decoding buffers do not need to be synchronized.
288    Actually, data can be produced by any source compliant with LZ4 format specification, and respecting maxBlockSize.
289  - Synchronized mode :
290    Decompression buffer size is _exactly_ the same as compression buffer size,
291    and follows exactly same update rule (block boundaries at same positions),
292    and decoding function is provided with exact decompressed size of each block (exception for last block of the stream),
293    _then_ decoding & encoding ring buffer can have any size, including small ones ( < 64 KB).
294  - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes.
295    In which case, encoding and decoding buffers do not need to be synchronized,
296    and encoding ring buffer can have any size, including small ones ( < 64 KB).
297
298  Whenever these conditions are not possible,
299  save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression,
300  then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block.
301</p></pre><BR>
302
303<pre><b>int LZ4_decompress_safe_usingDict (const char* src, char* dst, int srcSize, int dstCapcity, const char* dictStart, int dictSize);
304</b><p>  These decoding functions work the same as
305  a combination of LZ4_setStreamDecode() followed by LZ4_decompress_*_continue()
306  They are stand-alone, and don't need an LZ4_streamDecode_t structure.
307  Dictionary is presumed stable : it must remain accessible and unmodified during decompression.
308  Performance tip : Decompression speed can be substantially increased
309                    when dst == dictStart + dictSize.
310
311</p></pre><BR>
312
313<a name="Chapter8"></a><h2>Experimental section</h2><pre>
314 Symbols declared in this section must be considered unstable. Their
315 signatures or semantics may change, or they may be removed altogether in the
316 future. They are therefore only safe to depend on when the caller is
317 statically linked against the library.
318
319 To protect against unsafe usage, not only are the declarations guarded,
320 the definitions are hidden by default
321 when building LZ4 as a shared/dynamic library.
322
323 In order to access these declarations,
324 define LZ4_STATIC_LINKING_ONLY in your application
325 before including LZ4's headers.
326
327 In order to make their implementations accessible dynamically, you must
328 define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library.
329<BR></pre>
330
331<pre><b>LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
332</b><p>  A variant of LZ4_compress_fast_extState().
333
334  Using this variant avoids an expensive initialization step.
335  It is only safe to call if the state buffer is known to be correctly initialized already
336  (see above comment on LZ4_resetStream_fast() for a definition of "correctly initialized").
337  From a high level, the difference is that
338  this function initializes the provided state with a call to something like LZ4_resetStream_fast()
339  while LZ4_compress_fast_extState() starts with a call to LZ4_resetStream().
340
341</p></pre><BR>
342
343<pre><b>LZ4LIB_STATIC_API void LZ4_attach_dictionary(LZ4_stream_t* workingStream, const LZ4_stream_t* dictionaryStream);
344</b><p>  This is an experimental API that allows
345  efficient use of a static dictionary many times.
346
347  Rather than re-loading the dictionary buffer into a working context before
348  each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
349  working LZ4_stream_t, this function introduces a no-copy setup mechanism,
350  in which the working stream references the dictionary stream in-place.
351
352  Several assumptions are made about the state of the dictionary stream.
353  Currently, only streams which have been prepared by LZ4_loadDict() should
354  be expected to work.
355
356  Alternatively, the provided dictionaryStream may be NULL,
357  in which case any existing dictionary stream is unset.
358
359  If a dictionary is provided, it replaces any pre-existing stream history.
360  The dictionary contents are the only history that can be referenced and
361  logically immediately precede the data compressed in the first subsequent
362  compression call.
363
364  The dictionary will only remain attached to the working stream through the
365  first compression call, at the end of which it is cleared. The dictionary
366  stream (and source buffer) must remain in-place / accessible / unchanged
367  through the completion of the first compression call on the stream.
368
369</p></pre><BR>
370
371<pre><b></b><p>
372 It's possible to have input and output sharing the same buffer,
373 for highly contrained memory environments.
374 In both cases, it requires input to lay at the end of the buffer,
375 and decompression to start at beginning of the buffer.
376 Buffer size must feature some margin, hence be larger than final size.
377
378 |<------------------------buffer--------------------------------->|
379                             |<-----------compressed data--------->|
380 |<-----------decompressed size------------------>|
381                                                  |<----margin---->|
382
383 This technique is more useful for decompression,
384 since decompressed size is typically larger,
385 and margin is short.
386
387 In-place decompression will work inside any buffer
388 which size is >= LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize).
389 This presumes that decompressedSize > compressedSize.
390 Otherwise, it means compression actually expanded data,
391 and it would be more efficient to store such data with a flag indicating it's not compressed.
392 This can happen when data is not compressible (already compressed, or encrypted).
393
394 For in-place compression, margin is larger, as it must be able to cope with both
395 history preservation, requiring input data to remain unmodified up to LZ4_DISTANCE_MAX,
396 and data expansion, which can happen when input is not compressible.
397 As a consequence, buffer size requirements are much higher,
398 and memory savings offered by in-place compression are more limited.
399
400 There are ways to limit this cost for compression :
401 - Reduce history size, by modifying LZ4_DISTANCE_MAX.
402   Note that it is a compile-time constant, so all compressions will apply this limit.
403   Lower values will reduce compression ratio, except when input_size < LZ4_DISTANCE_MAX,
404   so it's a reasonable trick when inputs are known to be small.
405 - Require the compressor to deliver a "maximum compressed size".
406   This is the `dstCapacity` parameter in `LZ4_compress*()`.
407   When this size is < LZ4_COMPRESSBOUND(inputSize), then compression can fail,
408   in which case, the return code will be 0 (zero).
409   The caller must be ready for these cases to happen,
410   and typically design a backup scheme to send data uncompressed.
411 The combination of both techniques can significantly reduce
412 the amount of margin required for in-place compression.
413
414 In-place compression can work in any buffer
415 which size is >= (maxCompressedSize)
416 with maxCompressedSize == LZ4_COMPRESSBOUND(srcSize) for guaranteed compression success.
417 LZ4_COMPRESS_INPLACE_BUFFER_SIZE() depends on both maxCompressedSize and LZ4_DISTANCE_MAX,
418 so it's possible to reduce memory requirements by playing with them.
419
420</p></pre><BR>
421
422<pre><b>#define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize)   ((decompressedSize) + LZ4_DECOMPRESS_INPLACE_MARGIN(decompressedSize))  </b>/**< note: presumes that compressedSize < decompressedSize. note2: margin is overestimated a bit, since it could use compressedSize instead */<b>
423</b></pre><BR>
424<pre><b>#define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize)   ((maxCompressedSize) + LZ4_COMPRESS_INPLACE_MARGIN)  </b>/**< maxCompressedSize is generally LZ4_COMPRESSBOUND(inputSize), but can be set to any lower value, with the risk that compression can fail (return code 0(zero)) */<b>
425</b></pre><BR>
426<a name="Chapter9"></a><h2>PRIVATE DEFINITIONS</h2><pre>
427 Do not use these definitions directly.
428 They are only exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`.
429 Accessing members will expose code to API and/or ABI break in future versions of the library.
430<BR></pre>
431
432<pre><b>typedef struct {
433    const uint8_t* externalDict;
434    size_t extDictSize;
435    const uint8_t* prefixEnd;
436    size_t prefixSize;
437} LZ4_streamDecode_t_internal;
438</b></pre><BR>
439<pre><b>typedef struct {
440    const unsigned char* externalDict;
441    const unsigned char* prefixEnd;
442    size_t extDictSize;
443    size_t prefixSize;
444} LZ4_streamDecode_t_internal;
445</b></pre><BR>
446<pre><b>#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4 + ((sizeof(void*)==16) ? 4 : 0) </b>/*AS-400*/ )<b>
447#define LZ4_STREAMSIZE     (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long))
448union LZ4_stream_u {
449    unsigned long long table[LZ4_STREAMSIZE_U64];
450    LZ4_stream_t_internal internal_donotuse;
451} ;  </b>/* previously typedef'd to LZ4_stream_t */<b>
452</b><p>  information structure to track an LZ4 stream.
453  LZ4_stream_t can also be created using LZ4_createStream(), which is recommended.
454  The structure definition can be convenient for static allocation
455  (on stack, or as part of larger structure).
456  Init this structure with LZ4_initStream() before first use.
457  note : only use this definition in association with static linking !
458    this definition is not API/ABI safe, and may change in a future version.
459
460</p></pre><BR>
461
462<pre><b>LZ4_stream_t* LZ4_initStream (void* buffer, size_t size);
463</b><p>  An LZ4_stream_t structure must be initialized at least once.
464  This is automatically done when invoking LZ4_createStream(),
465  but it's not when the structure is simply declared on stack (for example).
466
467  Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t.
468  It can also initialize any arbitrary buffer of sufficient size,
469  and will @return a pointer of proper type upon initialization.
470
471  Note : initialization fails if size and alignment conditions are not respected.
472         In which case, the function will @return NULL.
473  Note2: An LZ4_stream_t structure guarantees correct alignment and size.
474  Note3: Before v1.9.0, use LZ4_resetStream() instead
475
476</p></pre><BR>
477
478<pre><b>#define LZ4_STREAMDECODESIZE_U64 (4 + ((sizeof(void*)==16) ? 2 : 0) </b>/*AS-400*/ )<b>
479#define LZ4_STREAMDECODESIZE     (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
480union LZ4_streamDecode_u {
481    unsigned long long table[LZ4_STREAMDECODESIZE_U64];
482    LZ4_streamDecode_t_internal internal_donotuse;
483} ;   </b>/* previously typedef'd to LZ4_streamDecode_t */<b>
484</b><p>  information structure to track an LZ4 stream during decompression.
485  init this structure  using LZ4_setStreamDecode() before first use.
486  note : only use in association with static linking !
487         this definition is not API/ABI safe,
488         and may change in a future version !
489
490</p></pre><BR>
491
492<a name="Chapter10"></a><h2>Obsolete Functions</h2><pre></pre>
493
494<pre><b>#ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
495#  define LZ4_DEPRECATED(message)   </b>/* disable deprecation warnings */<b>
496#else
497#  define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
498#  if defined (__cplusplus) && (__cplusplus >= 201402) </b>/* C++14 or greater */<b>
499#    define LZ4_DEPRECATED(message) [[deprecated(message)]]
500#  elif (LZ4_GCC_VERSION >= 405) || defined(__clang__)
501#    define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
502#  elif (LZ4_GCC_VERSION >= 301)
503#    define LZ4_DEPRECATED(message) __attribute__((deprecated))
504#  elif defined(_MSC_VER)
505#    define LZ4_DEPRECATED(message) __declspec(deprecated(message))
506#  else
507#    pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
508#    define LZ4_DEPRECATED(message)
509#  endif
510#endif </b>/* LZ4_DISABLE_DEPRECATE_WARNINGS */<b>
511</b><p>
512  Deprecated functions make the compiler generate a warning when invoked.
513  This is meant to invite users to update their source code.
514  Should deprecation warnings be a problem, it is generally possible to disable them,
515  typically with -Wno-deprecated-declarations for gcc
516  or _CRT_SECURE_NO_WARNINGS in Visual.
517
518  Another method is to define LZ4_DISABLE_DEPRECATE_WARNINGS
519  before including the header file.
520
521</p></pre><BR>
522
523<pre><b></b><p>  These functions used to be faster than LZ4_decompress_safe(),
524  but it has changed, and they are now slower than LZ4_decompress_safe().
525  This is because LZ4_decompress_fast() doesn't know the input size,
526  and therefore must progress more cautiously in the input buffer to not read beyond the end of block.
527  On top of that `LZ4_decompress_fast()` is not protected vs malformed or malicious inputs, making it a security liability.
528  As a consequence, LZ4_decompress_fast() is strongly discouraged, and deprecated.
529
530  The last remaining LZ4_decompress_fast() specificity is that
531  it can decompress a block without knowing its compressed size.
532  Such functionality could be achieved in a more secure manner,
533  by also providing the maximum size of input buffer,
534  but it would require new prototypes, and adaptation of the implementation to this new use case.
535
536  Parameters:
537  originalSize : is the uncompressed size to regenerate.
538                 `dst` must be already allocated, its size must be >= 'originalSize' bytes.
539 @return : number of bytes read from source buffer (== compressed size).
540           The function expects to finish at block's end exactly.
541           If the source stream is detected malformed, the function stops decoding and returns a negative result.
542  note : LZ4_decompress_fast*() requires originalSize. Thanks to this information, it never writes past the output buffer.
543         However, since it doesn't know its 'src' size, it may read an unknown amount of input, past input buffer bounds.
544         Also, since match offsets are not validated, match reads from 'src' may underflow too.
545         These issues never happen if input (compressed) data is correct.
546         But they may happen if input data is invalid (error or intentional tampering).
547         As a consequence, use these functions in trusted environments with trusted data **only**.
548
549</p></pre><BR>
550
551<pre><b>void LZ4_resetStream (LZ4_stream_t* streamPtr);
552</b><p>  An LZ4_stream_t structure must be initialized at least once.
553  This is done with LZ4_initStream(), or LZ4_resetStream().
554  Consider switching to LZ4_initStream(),
555  invoking LZ4_resetStream() will trigger deprecation warnings in the future.
556
557</p></pre><BR>
558
559</html>
560</body>
561