GRASS 8 Programmer's Manual  8.5.0dev(2025)-c070206eb1
lz4.h
Go to the documentation of this file.
1 /*
2  * LZ4 - Fast LZ compression algorithm
3  * Header File
4  * Copyright (C) 2011-2023, Yann Collet.
5 
6  BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are
10  met:
11 
12  * Redistributions of source code must retain the above copyright
13  notice, this list of conditions and the following disclaimer.
14  * Redistributions in binary form must reproduce the above
15  copyright notice, this list of conditions and the following disclaimer
16  in the documentation and/or other materials provided with the
17  distribution.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31  You can contact the author at :
32  - LZ4 homepage : http://www.lz4.org
33  - LZ4 source repository : https://github.com/lz4/lz4
34 */
35 #if defined(__cplusplus)
36 extern "C" {
37 #endif
38 
39 #ifndef LZ4_H_2983827168210
40 #define LZ4_H_2983827168210
41 
42 /* --- Dependency --- */
43 #include <stddef.h> /* size_t */
44 
45 /**
46  Introduction
47 
48  LZ4 is lossless compression algorithm, providing compression speed >500 MB/s
49  per core, scalable with multi-cores CPU. It features an extremely fast
50  decoder, with speed in multiple GB/s per core, typically reaching RAM speed
51  limits on multi-core systems.
52 
53  The LZ4 compression library provides in-memory compression and decompression
54  functions. It gives full buffer control to user. Compression can be done in:
55  - a single step (described as Simple Functions)
56  - a single step, reusing a context (described in Advanced Functions)
57  - unbounded multiple steps (described as Streaming compression)
58 
59  lz4.h generates and decodes LZ4-compressed blocks (doc/lz4_Block_format.md).
60  Decompressing such a compressed block requires additional metadata.
61  Exact metadata depends on exact decompression function.
62  For the typical case of LZ4_decompress_safe(),
63  metadata includes block's compressed size, and maximum bound of decompressed
64  size. Each application is free to encode and pass such metadata in whichever
65  way it wants.
66 
67  lz4.h only handle blocks, it can not generate Frames.
68 
69  Blocks are different from Frames (doc/lz4_Frame_format.md).
70  Frames bundle both blocks and metadata in a specified manner.
71  Embedding metadata is required for compressed data to be self-contained and
72  portable. Frame format is delivered through a companion API, declared in
73  lz4frame.h. The `lz4` CLI can only manage frames.
74 */
75 
76 /*^***************************************************************
77  * Export parameters
78  *****************************************************************/
79 /*
80  * LZ4_DLL_EXPORT :
81  * Enable exporting of functions when building a Windows DLL
82  * LZ4LIB_VISIBILITY :
83  * Control library symbols visibility.
84  */
85 #ifndef LZ4LIB_VISIBILITY
86 #if defined(__GNUC__) && (__GNUC__ >= 4)
87 #define LZ4LIB_VISIBILITY __attribute__((visibility("default")))
88 #else
89 #define LZ4LIB_VISIBILITY
90 #endif
91 #endif
92 #if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT == 1)
93 #define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY
94 #elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT == 1)
95 #define LZ4LIB_API \
96  __declspec(dllimport) \
97  LZ4LIB_VISIBILITY /* It isn't required but allows to generate better code, \
98  saving a function pointer load from the IAT and an \
99  indirect jump.*/
100 #else
101 #define LZ4LIB_API LZ4LIB_VISIBILITY
102 #endif
103 
104 /*! LZ4_FREESTANDING :
105  * When this macro is set to 1, it enables "freestanding mode" that is
106  * suitable for typical freestanding environment which doesn't support
107  * standard C library.
108  *
109  * - LZ4_FREESTANDING is a compile-time switch.
110  * - It requires the following macros to be defined:
111  * LZ4_memcpy, LZ4_memmove, LZ4_memset.
112  * - It only enables LZ4/HC functions which don't use heap.
113  * All LZ4F_* functions are not supported.
114  * - See tests/freestanding.c to check its basic setup.
115  */
116 #if defined(LZ4_FREESTANDING) && (LZ4_FREESTANDING == 1)
117 #define LZ4_HEAPMODE 0
118 #define LZ4HC_HEAPMODE 0
119 #define LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION 1
120 #if !defined(LZ4_memcpy)
121 #error "LZ4_FREESTANDING requires macro 'LZ4_memcpy'."
122 #endif
123 #if !defined(LZ4_memset)
124 #error "LZ4_FREESTANDING requires macro 'LZ4_memset'."
125 #endif
126 #if !defined(LZ4_memmove)
127 #error "LZ4_FREESTANDING requires macro 'LZ4_memmove'."
128 #endif
129 #elif !defined(LZ4_FREESTANDING)
130 #define LZ4_FREESTANDING 0
131 #endif
132 
133 /*------ Version ------*/
134 #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
135 #define LZ4_VERSION_MINOR \
136  10 /* for new (non-breaking) interface capabilities \
137  */
138 #define LZ4_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */
139 
140 #define LZ4_VERSION_NUMBER \
141  (LZ4_VERSION_MAJOR * 100 * 100 + LZ4_VERSION_MINOR * 100 + \
142  LZ4_VERSION_RELEASE)
143 
144 #define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
145 #define LZ4_QUOTE(str) #str
146 #define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
147 #define LZ4_VERSION_STRING \
148  LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) /* requires v1.7.3+ */
149 
150 LZ4LIB_API int
151 LZ4_versionNumber(void); /**< library version number; useful to check dll
152  version; requires v1.3.0+ */
153 LZ4LIB_API const char *
154 LZ4_versionString(void); /**< library version string; useful to check dll
155  version; requires v1.7.5+ */
156 
157 /*-************************************
158  * Tuning memory usage
159  **************************************/
160 /*!
161  * LZ4_MEMORY_USAGE :
162  * Can be selected at compile time, by setting LZ4_MEMORY_USAGE.
163  * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 ->
164  * 64KB; 20 -> 1MB) Increasing memory usage improves compression ratio,
165  * generally at the cost of speed. Reduced memory usage may improve speed at the
166  * cost of ratio, thanks to better cache locality.
167  * Default value is 14, for 16KB, which nicely fits into most L1 caches.
168  */
169 #ifndef LZ4_MEMORY_USAGE
170 #define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
171 #endif
172 
173 /* These are absolute limits, they should not be changed by users */
174 #define LZ4_MEMORY_USAGE_MIN 10
175 #define LZ4_MEMORY_USAGE_DEFAULT 14
176 #define LZ4_MEMORY_USAGE_MAX 20
177 
178 #if (LZ4_MEMORY_USAGE < LZ4_MEMORY_USAGE_MIN)
179 #error "LZ4_MEMORY_USAGE is too small !"
180 #endif
181 
182 #if (LZ4_MEMORY_USAGE > LZ4_MEMORY_USAGE_MAX)
183 #error "LZ4_MEMORY_USAGE is too large !"
184 #endif
185 
186 /*-************************************
187  * Simple Functions
188  **************************************/
189 /*! LZ4_compress_default() :
190  * Compresses 'srcSize' bytes from buffer 'src'
191  * into already allocated 'dst' buffer of size 'dstCapacity'.
192  * Compression is guaranteed to succeed if 'dstCapacity' >=
193  * LZ4_compressBound(srcSize).
194  * It also runs faster, so it's a recommended setting.
195  * If the function cannot compress 'src' into a more limited 'dst' budget,
196  * compression stops *immediately*, and the function result is zero.
197  * In which case, 'dst' content is undefined (invalid).
198  * @param srcSize max supported value is LZ4_MAX_INPUT_SIZE.
199  * @param dstCapacity size of buffer 'dst' (which must be already allocated)
200  * @return the number of bytes written into buffer 'dst' (necessarily <=
201  * dstCapacity) or 0 if compression fails
202  * Note : This function is protected against buffer overflow scenarios (never
203  * writes outside 'dst' buffer, nor read outside 'source' buffer).
204  */
205 LZ4LIB_API int LZ4_compress_default(const char *src, char *dst, int srcSize,
206  int dstCapacity);
207 
208 /*! LZ4_decompress_safe() :
209  * @param src
210  * @param dst
211  * @param compressedSize is the exact complete size of the compressed block.
212  * @param dstCapacity is the size of destination buffer (which must be already
213  * allocated), presumed an upper bound of decompressed
214  * size.
215  * @return the number of bytes decompressed into destination buffer
216  * (necessarily <= dstCapacity)
217  * If destination buffer is not large enough,
218  * decoding will stop and output an error code (negative value).
219  * If the source stream is detected malformed, the function will stop
220  * decoding and return a negative result.
221  *
222  * Note 1 : This function is protected against malicious data packets :
223  * it will never write outside 'dst' buffer, nor read outside 'source'
224  * buffer, even if the compressed block is maliciously modified to
225  * order the decoder to do these actions. In such case, the decoder
226  * stops immediately, andconsiders the compressed block malformed.
227  *
228  * Note 2 : compressedSize and dstCapacity must be provided to the function, the
229  * compressed block does not contain them.
230  * The implementation is free to send / store / derive this information
231  * in whichever way is most beneficial.
232  * If there is a need for a different format which bundles together
233  * both compressed data and its metadata, consider looking at
234  * lz4frame.h instead.
235  */
236 LZ4LIB_API int LZ4_decompress_safe(const char *src, char *dst,
237  int compressedSize, int dstCapacity);
238 
239 /*-************************************
240  * Advanced Functions
241  **************************************/
242 #define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
243 #define LZ4_COMPRESSBOUND(isize) \
244  ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE \
245  ? 0 \
246  : (isize) + ((isize) / 255) + 16)
247 
248 /*! LZ4_compressBound() :
249  Provides the maximum size that LZ4 compression may output in a "worst case"
250  scenario (input data not compressible)
251  This function is primarily useful for memory allocation purposes (destination
252  buffer size).
253  Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation
254  (stack memory allocation for example).
255  Note that LZ4_compress_default() compresses faster when dstCapacity is >=
256  LZ4_compressBound(srcSize)
257  @param inputSize max supported value is LZ4_MAX_INPUT_SIZE
258  @return maximum output size in a "worst case" scenario or 0, if input size is
259  incorrect (too large or negative)
260 */
261 LZ4LIB_API int LZ4_compressBound(int inputSize);
262 
263 /*! LZ4_compress_fast() :
264  Same as LZ4_compress_default(), but allows selection of "acceleration"
265  factor.
266  The larger the acceleration value, the faster the algorithm, but also
267  the lesser the compression.
268  It's a trade-off. It can be fine tuned, with each successive value providing
269  roughly +~3% to speed.
270  An acceleration value of "1" is the same as regular LZ4_compress_default()
271  Values <= 0 will be replaced by LZ4_ACCELERATION_DEFAULT
272  (currently == 1, see lz4.c).
273  Values > LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX
274  (currently == 65537, see lz4.c).
275 */
276 LZ4LIB_API int LZ4_compress_fast(const char *src, char *dst, int srcSize,
277  int dstCapacity, int acceleration);
278 
279 /*! LZ4_compress_fast_extState() :
280  * Same as LZ4_compress_fast(), using an externally allocated memory space for
281  * its state. Use LZ4_sizeofState() to know how much memory must be allocated,
282  * and allocate it on 8-bytes boundaries (using `malloc()` typically).
283  * Then, provide this buffer as `void* state` to compression function.
284  */
285 LZ4LIB_API int LZ4_sizeofState(void);
286 LZ4LIB_API int LZ4_compress_fast_extState(void *state, const char *src,
287  char *dst, int srcSize,
288  int dstCapacity, int acceleration);
289 
290 /*! LZ4_compress_destSize() :
291  * Reverse the logic : compresses as much data as possible from 'src' buffer
292  * into already allocated buffer 'dst', of size >= 'dstCapacity'.
293  * This function either compresses the entire 'src' content into 'dst' if it's
294  * large enough, or fill 'dst' buffer completely with as much data as possible
295  * from 'src'. note: acceleration parameter is fixed to "default".
296  *
297  * @param[in,out] srcSizePtr Initially contains size of input.
298  * Will be modified to indicate how many bytes where
299  * read from 'src' to fill 'dst'.
300  * New value is necessarily <= input value.
301  * @return Nb bytes written into 'dst' (necessarily <= dstCapacity)
302  * or 0 if compression fails.
303  *
304  * Note : from v1.8.2 to v1.9.1, this function had a bug (fixed in v1.9.2+):
305  * the produced compressed content could, in specific circumstances,
306  * require to be decompressed into a destination buffer larger
307  * by at least 1 byte than the content to decompress.
308  * If an application uses `LZ4_compress_destSize()`,
309  * it's highly recommended to update liblz4 to v1.9.2 or better.
310  * If this can't be done or ensured,
311  * the receiving decompression function should provide
312  * a dstCapacity which is > decompressedSize, by at least 1 byte.
313  * See https://github.com/lz4/lz4/issues/859 for details
314  */
315 LZ4LIB_API int LZ4_compress_destSize(const char *src, char *dst,
316  int *srcSizePtr, int targetDstSize);
317 
318 /*! LZ4_decompress_safe_partial() :
319  * Decompress an LZ4 compressed block, of size 'srcSize' at position 'src',
320  * into destination buffer 'dst' of size 'dstCapacity'.
321  * Up to 'targetOutputSize' bytes will be decoded.
322  * The function stops decoding on reaching this objective.
323  * This can be useful to boost performance
324  * whenever only the beginning of a block is required.
325  *
326  * @return the number of bytes decoded in `dst` (necessarily <=
327  * \p targetOutputSize)
328  * If source stream is detected malformed, function returns a negative
329  * result.
330  *
331  * Note 1 : @return can be < \p targetOutputSize, if compressed block contains
332  * less data.
333  *
334  * Note 2 : \p targetOutputSize must be <= \p dstCapacity
335  *
336  * Note 3 : this function effectively stops decoding on reaching
337  * \p targetOutputSize, so \p dstCapacity is kind of redundant.
338  * This is because in older versions of this function, decoding
339  * operation would still write complete sequences.
340  * Therefore, there was no guarantee that it would stop writing at
341  * exactly \p targetOutputSize, it could write more bytes,
342  * though only up to \p dstCapacity. Some "margin" used to be required
343  * for this operation to work properly.
344  * Thankfully, this is no longer necessary.
345  * The function nonetheless keeps the same signature, in an effort to
346  * preserve API compatibility.
347  *
348  * Note 4 : If \p srcSize is the exact size of the block,
349  * then \p targetOutputSize can be any value,
350  * including larger than the block's decompressed size.
351  * The function will, at most, generate block's decompressed size.
352  *
353  * Note 5 : If \p srcSize is _larger_ than block's compressed size,
354  * then \p targetOutputSize **MUST** be <= block's decompressed size.
355  * Otherwise, *silent corruption will occur*.
356  */
357 LZ4LIB_API int LZ4_decompress_safe_partial(const char *src, char *dst,
358  int srcSize, int targetOutputSize,
359  int dstCapacity);
360 
361 /*-*********************************************
362  * Streaming Compression Functions
363  ***********************************************/
364 typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
365 
366 /*!
367  Note about RC_INVOKED
368 
369  - RC_INVOKED is predefined symbol of rc.exe (the resource compiler which is
370  part of MSVC/Visual Studio).
371  https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros
372 
373  - Since rc.exe is a legacy compiler, it truncates long symbol (> 30 chars)
374  and reports warning "RC4011: identifier truncated".
375 
376  - To eliminate the warning, we surround long preprocessor symbol with
377  "#if !defined(RC_INVOKED) ... #endif" block that means
378  "skip this block when rc.exe is trying to read it".
379 */
380 #if !defined( \
381  RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros \
382  */
383 #if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
385 LZ4LIB_API int LZ4_freeStream(LZ4_stream_t *streamPtr);
386 #endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
387 #endif
388 
389 /*! LZ4_resetStream_fast() : v1.9.0+
390  * Use this to prepare an LZ4_stream_t for a new chain of dependent blocks
391  * (e.g., LZ4_compress_fast_continue()).
392  *
393  * An LZ4_stream_t must be initialized once before usage.
394  * This is automatically done when created by LZ4_createStream().
395  * However, should the LZ4_stream_t be simply declared on stack (for example),
396  * it's necessary to initialize it first, using LZ4_initStream().
397  *
398  * After init, start any new stream with LZ4_resetStream_fast().
399  * A same LZ4_stream_t can be re-used multiple times consecutively
400  * and compress multiple streams,
401  * provided that it starts each new stream with LZ4_resetStream_fast().
402  *
403  * LZ4_resetStream_fast() is much faster than LZ4_initStream(),
404  * but is not compatible with memory regions containing garbage data.
405  *
406  * Note: it's only useful to call LZ4_resetStream_fast()
407  * in the context of streaming compression.
408  * The *extState* functions perform their own resets.
409  * Invoking LZ4_resetStream_fast() before is redundant, and even
410  * counterproductive.
411  */
413 
414 /*! LZ4_loadDict() :
415  * Use this function to reference a static dictionary into LZ4_stream_t.
416  * The dictionary must remain available during compression.
417  * LZ4_loadDict() triggers a reset, so any previous data will be forgotten.
418  * The same dictionary will have to be loaded on decompression side for
419  * successful decoding. Dictionary are useful for better compression of small
420  * data (KB range). While LZ4 itself accepts any input as dictionary, dictionary
421  * efficiency is also a topic. When in doubt, employ the Zstandard's Dictionary
422  * Builder. Loading a size of 0 is allowed, and is the same as reset.
423  *
424  * @return loaded dictionary size, in bytes (note: only the last 64 KB are
425  * loaded)
426  */
427 LZ4LIB_API int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary,
428  int dictSize);
429 
430 /*! LZ4_loadDictSlow() : v1.10.0+
431  * Same as LZ4_loadDict(),
432  * but uses a bit more cpu to reference the dictionary content more thoroughly.
433  * This is expected to slightly improve compression ratio.
434  * The extra-cpu cost is likely worth it if the dictionary is re-used across
435  * multiple sessions.
436  * @return loaded dictionary size, in bytes (note: only the last 64 KB are
437  * loaded)
438  */
439 LZ4LIB_API int LZ4_loadDictSlow(LZ4_stream_t *streamPtr, const char *dictionary,
440  int dictSize);
441 
442 /*! LZ4_attach_dictionary() : stable since v1.10.0
443  *
444  * This allows efficient re-use of a static dictionary multiple times.
445  *
446  * Rather than re-loading the dictionary buffer into a working context before
447  * each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
448  * working LZ4_stream_t, this function introduces a no-copy setup mechanism,
449  * in which the working stream references \p dictionaryStream in-place.
450  *
451  * Several assumptions are made about the state of \p dictionaryStream.
452  * Currently, only states which have been prepared by LZ4_loadDict() or
453  * LZ4_loadDictSlow() should be expected to work.
454  *
455  * Alternatively, the provided \p dictionaryStream may be NULL,
456  * in which case any existing dictionary stream is unset.
457  *
458  * If a dictionary is provided, it replaces any pre-existing stream history.
459  * The dictionary contents are the only history that can be referenced and
460  * logically immediately precede the data compressed in the first subsequent
461  * compression call.
462  *
463  * The dictionary will only remain attached to the working stream through the
464  * first compression call, at the end of which it is cleared.
465  * \p dictionaryStream stream (and source buffer) must remain in-place /
466  * accessible / unchanged through the completion of the compression session.
467  *
468  * Note: there is no equivalent LZ4_attach_*() method on the decompression side
469  * because there is no initialization cost, hence no need to share the cost
470  * across multiple sessions. To decompress LZ4 blocks using dictionary, attached
471  * or not, just employ the regular LZ4_setStreamDecode() for streaming, or the
472  * stateless LZ4_decompress_safe_usingDict() for one-shot decompression.
473  */
474 LZ4LIB_API void LZ4_attach_dictionary(LZ4_stream_t *workingStream,
475  const LZ4_stream_t *dictionaryStream);
476 
477 /*! LZ4_compress_fast_continue() :
478  * Compress 'src' content using data from previously compressed blocks, for
479  * better compression ratio. 'dst' buffer must be already allocated. If
480  * dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to
481  * succeed, and runs faster.
482  *
483  * @return size of compressed block
484  * or 0 if there is an error (typically, cannot fit into 'dst').
485  *
486  * Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new
487  * block.
488  * Each block has precise boundaries.
489  * Each block must be decompressed separately, calling
490  * LZ4_decompress_*() with relevant metadata.
491  * It's not possible to append blocks together and expect a single
492  * invocation of LZ4_decompress_*() to decompress them together.
493  *
494  * Note 2 : The previous 64KB of source data is __assumed__ to remain present,
495  * unmodified, at same address in memory !
496  *
497  * Note 3 : When input is structured as a double-buffer, each buffer can have
498  * any size, including < 64 KB.
499  * Make sure that buffers are separated, by at least one byte.
500  * This construction ensures that each block only depends on previous
501  * block.
502  *
503  * Note 4 : If input buffer is a ring-buffer, it can have any size, including <
504  * 64 KB.
505  *
506  * Note 5 : After an error, the stream status is undefined (invalid), it can
507  * only be reset or freed.
508  */
510  const char *src, char *dst,
511  int srcSize, int dstCapacity,
512  int acceleration);
513 
514 /*! LZ4_saveDict() :
515  * If last 64KB data cannot be guaranteed to remain available at its current
516  * memory location, save it into a safer place (char* safeBuffer).
517  * This is schematically equivalent to a memcpy() followed by LZ4_loadDict(),
518  * but is much faster, because LZ4_saveDict() doesn't need to rebuild tables.
519  * @return saved dictionary size in bytes (necessarily <= maxDictSize), or 0
520  * if error.
521  */
522 LZ4LIB_API int LZ4_saveDict(LZ4_stream_t *streamPtr, char *safeBuffer,
523  int maxDictSize);
524 
525 /*-**********************************************
526  * Streaming Decompression Functions
527  * Bufferless synchronous API
528  ************************************************/
529 typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
530 
531 /*! LZ4_createStreamDecode() and LZ4_freeStreamDecode() :
532  * creation / destruction of streaming decompression tracking context.
533  * A tracking context can be re-used multiple times.
534  */
535 #if !defined( \
536  RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros \
537  */
538 #if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
541 #endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
542 #endif
543 
544 /*! LZ4_setStreamDecode() :
545  * An LZ4_streamDecode_t context can be allocated once and re-used multiple
546  * times. Use this function to start decompression of a new stream of blocks.
547  * A dictionary can optionally be set. Use NULL or size 0 for a reset order.
548  * Dictionary is presumed stable : it must remain accessible and unmodified
549  * during next decompression.
550  * @return 1 if OK, 0 if error
551  */
553  const char *dictionary, int dictSize);
554 
555 /*! LZ4_decoderRingBufferSize() : v1.8.2+
556  * Note : in a ring buffer scenario (optional),
557  * blocks are presumed decompressed next to each other
558  * up to the moment there is not enough remaining space for next block
559  * (remainingSize < maxBlockSize), at which stage it resumes from
560  * beginning of ring buffer. When setting such a ring buffer for
561  * streaming decompression, provides the minimum size of this ring buffer
562  * to be compatible with any source respecting maxBlockSize condition.
563  * @return : minimum ring buffer size,
564  * or 0 if there is an error (invalid maxBlockSize).
565  */
566 LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
567 #define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) \
568  (65536 + 14 + \
569  (maxBlockSize)) /* for static allocation; maxBlockSize presumed valid */
570 
571 /*! LZ4_decompress_safe_continue() :
572  * This decoding function allows decompression of consecutive blocks in
573  * "streaming" mode. The difference with the usual independent blocks is that
574  * new blocks are allowed to find references into former blocks.
575  * A block is an unsplittable entity, and must be presented entirely to the
576  * decompression function. LZ4_decompress_safe_continue() only accepts one block
577  * at a time. It's modeled after `LZ4_decompress_safe()` and behaves similarly.
578  *
579  * @param LZ4_streamDecode decompression state, tracking the position in
580  * memory of past data
581  * @param compressedSize exact complete size of one compressed block.
582  * @param dstCapacity size of destination buffer (which must be already
583  * allocated), must be an upper bound of decompressed size.
584  * @return number of bytes decompressed into destination buffer (necessarily
585  * <= \p dstCapacity) If destination buffer is not large enough,
586  * decoding will stop and output an error code (negative value). If the source
587  * stream is detected malformed, the function will stop decoding and return a
588  * negative result.
589  *
590  * The last 64KB of previously decoded data *must* remain available and
591  * unmodified at the memory position where they were previously decoded. If less
592  * than 64KB of data has been decoded, all the data must be present.
593  *
594  * Special : if decompression side sets a ring buffer, it must respect one of
595  * the following conditions :
596  * - Decompression buffer size is _at least_
597  * LZ4_decoderRingBufferSize(maxBlockSize). maxBlockSize is the maximum size of
598  * any single block. It can have any value > 16 bytes. In which case, encoding
599  * and decoding buffers do not need to be synchronized. Actually, data can be
600  * produced by any source compliant with LZ4 format specification, and
601  * respecting maxBlockSize.
602  * - Synchronized mode :
603  * Decompression buffer size is _exactly_ the same as compression buffer
604  * size, and follows exactly same update rule (block boundaries at same
605  * positions), and decoding function is provided with exact decompressed size of
606  * each block (exception for last block of the stream), _then_ decoding &
607  * encoding ring buffer can have any size, including small ones ( < 64 KB).
608  * - Decompression buffer is larger than encoding buffer, by a minimum of
609  * maxBlockSize more bytes. In which case, encoding and decoding buffers do not
610  * need to be synchronized, and encoding ring buffer can have any size,
611  * including small ones ( < 64 KB).
612  *
613  * Whenever these conditions are not possible,
614  * save the last 64KB of decoded data into a safe buffer where it can't be
615  * modified during decompression, then indicate where this data is saved using
616  * LZ4_setStreamDecode(), before decompressing next block.
617  */
620  const char *src, char *dst, int srcSize,
621  int dstCapacity);
622 
623 /*! LZ4_decompress_safe_usingDict() :
624  * Works the same as
625  * a combination of LZ4_setStreamDecode() followed by
626  * LZ4_decompress_safe_continue()
627  * However, it's stateless: it doesn't need any LZ4_streamDecode_t state.
628  * Dictionary is presumed stable : it must remain accessible and unmodified
629  * during decompression.
630  * Performance tip : Decompression speed can be substantially increased
631  * when dst == dictStart + dictSize.
632  */
633 LZ4LIB_API int LZ4_decompress_safe_usingDict(const char *src, char *dst,
634  int srcSize, int dstCapacity,
635  const char *dictStart,
636  int dictSize);
637 
638 /*! LZ4_decompress_safe_partial_usingDict() :
639  * Behaves the same as LZ4_decompress_safe_partial()
640  * with the added ability to specify a memory segment for past data.
641  * Performance tip : Decompression speed can be substantially increased
642  * when dst == dictStart + dictSize.
643  */
645  const char *src, char *dst, int compressedSize, int targetOutputSize,
646  int maxOutputSize, const char *dictStart, int dictSize);
647 
648 #endif /* LZ4_H_2983827168210 */
649 
650 /*^*************************************
651  * !!!!!! STATIC LINKING ONLY !!!!!!
652  ***************************************/
653 
654 /*-****************************************************************************
655  * Experimental section
656  *
657  * Symbols declared in this section must be considered unstable. Their
658  * signatures or semantics may change, or they may be removed altogether in the
659  * future. They are therefore only safe to depend on when the caller is
660  * statically linked against the library.
661  *
662  * To protect against unsafe usage, not only are the declarations guarded,
663  * the definitions are hidden by default
664  * when building LZ4 as a shared/dynamic library.
665  *
666  * In order to access these declarations,
667  * define LZ4_STATIC_LINKING_ONLY in your application
668  * before including LZ4's headers.
669  *
670  * In order to make their implementations accessible dynamically, you must
671  * define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library.
672  ******************************************************************************/
673 
674 #ifdef LZ4_STATIC_LINKING_ONLY
675 
676 #ifndef LZ4_STATIC_3504398509
677 #define LZ4_STATIC_3504398509
678 
679 #ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
680 #define LZ4LIB_STATIC_API LZ4LIB_API
681 #else
682 #define LZ4LIB_STATIC_API
683 #endif
684 
685 /*! LZ4_compress_fast_extState_fastReset() :
686  * A variant of LZ4_compress_fast_extState().
687  *
688  * Using this variant avoids an expensive initialization step.
689  * It is only safe to call if the state buffer is known to be correctly
690  * initialized already (see above comment on LZ4_resetStream_fast() for a
691  * definition of "correctly initialized"). From a high level, the difference is
692  * that this function initializes the provided state with a call to something
693  * like LZ4_resetStream_fast() while LZ4_compress_fast_extState() starts with a
694  * call to LZ4_resetStream().
695  */
696 LZ4LIB_STATIC_API int
697 LZ4_compress_fast_extState_fastReset(void *state, const char *src, char *dst,
698  int srcSize, int dstCapacity,
699  int acceleration);
700 
701 /*! LZ4_compress_destSize_extState() : introduced in v1.10.0
702  * Same as LZ4_compress_destSize(), but using an externally allocated state.
703  * Also: exposes @acceleration
704  */
705 int LZ4_compress_destSize_extState(void *state, const char *src, char *dst,
706  int *srcSizePtr, int targetDstSize,
707  int acceleration);
708 
709 /*! In-place compression and decompression
710  *
711  * It's possible to have input and output sharing the same buffer,
712  * for highly constrained memory environments.
713  * In both cases, it requires input to lay at the end of the buffer,
714  * and decompression to start at beginning of the buffer.
715  * Buffer size must feature some margin, hence be larger than final size.
716  *
717  * |<------------------------buffer--------------------------------->|
718  * |<-----------compressed data--------->|
719  * |<-----------decompressed size------------------>|
720  * |<----margin---->|
721  *
722  * This technique is more useful for decompression,
723  * since decompressed size is typically larger,
724  * and margin is short.
725  *
726  * In-place decompression will work inside any buffer
727  * which size is >= LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize).
728  * This presumes that decompressedSize > compressedSize.
729  * Otherwise, it means compression actually expanded data,
730  * and it would be more efficient to store such data with a flag indicating it's
731  * not compressed. This can happen when data is not compressible (already
732  * compressed, or encrypted).
733  *
734  * For in-place compression, margin is larger, as it must be able to cope with
735  * both history preservation, requiring input data to remain unmodified up to
736  * LZ4_DISTANCE_MAX, and data expansion, which can happen when input is not
737  * compressible. As a consequence, buffer size requirements are much higher, and
738  * memory savings offered by in-place compression are more limited.
739  *
740  * There are ways to limit this cost for compression :
741  * - Reduce history size, by modifying LZ4_DISTANCE_MAX.
742  * Note that it is a compile-time constant, so all compressions will apply
743  * this limit. Lower values will reduce compression ratio, except when
744  * input_size < LZ4_DISTANCE_MAX, so it's a reasonable trick when inputs are
745  * known to be small.
746  * - Require the compressor to deliver a "maximum compressed size".
747  * This is the `dstCapacity` parameter in `LZ4_compress*()`.
748  * When this size is < LZ4_COMPRESSBOUND(inputSize), then compression can
749  * fail, in which case, the return code will be 0 (zero). The caller must be
750  * ready for these cases to happen, and typically design a backup scheme to send
751  * data uncompressed. The combination of both techniques can significantly
752  * reduce the amount of margin required for in-place compression.
753  *
754  * In-place compression can work in any buffer
755  * which size is >= (maxCompressedSize)
756  * with maxCompressedSize == LZ4_COMPRESSBOUND(srcSize) for guaranteed
757  * compression success. LZ4_COMPRESS_INPLACE_BUFFER_SIZE() depends on both
758  * maxCompressedSize and LZ4_DISTANCE_MAX, so it's possible to reduce memory
759  * requirements by playing with them.
760  */
761 
762 #define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) \
763  (((compressedSize) >> 8) + 32)
764 #define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize) \
765  ((decompressedSize) + \
766  LZ4_DECOMPRESS_INPLACE_MARGIN( \
767  decompressedSize)) /**< note: presumes that compressedSize < \
768  decompressedSize. note2: margin is \
769  overestimated a bit, since it could use \
770  compressedSize instead */
771 
772 #ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at \
773  compile time */
774 #define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
775 #endif
776 
777 #define LZ4_COMPRESS_INPLACE_MARGIN \
778  (LZ4_DISTANCE_MAX + 32) /* LZ4_DISTANCE_MAX can be safely replaced by \
779  srcSize when it's smaller */
780 #define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize) \
781  ((maxCompressedSize) + \
782  LZ4_COMPRESS_INPLACE_MARGIN) /**< maxCompressedSize is generally \
783  LZ4_COMPRESSBOUND(inputSize), but can be \
784  set to any lower value, with the risk \
785  that compression can fail (return code \
786  0(zero)) */
787 
788 #endif /* LZ4_STATIC_3504398509 */
789 #endif /* LZ4_STATIC_LINKING_ONLY */
790 
791 #ifndef LZ4_H_98237428734687
792 #define LZ4_H_98237428734687
793 
794 /*-************************************************************
795  * Private Definitions
796  **************************************************************
797  * Do not use these definitions directly.
798  * They are only exposed to allow static allocation of `LZ4_stream_t` and
799  *`LZ4_streamDecode_t`. Accessing members will expose user code to API and/or
800  *ABI break in future versions of the library.
801  **************************************************************/
802 #define LZ4_HASHLOG (LZ4_MEMORY_USAGE - 2)
803 #define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
804 #define LZ4_HASH_SIZE_U32 \
805  (1 << LZ4_HASHLOG) /* required as macro for static allocation */
806 
807 #if defined(__cplusplus) || \
808  (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
809 #include <stdint.h>
810 typedef int8_t LZ4_i8;
811 typedef uint8_t LZ4_byte;
812 typedef uint16_t LZ4_u16;
813 typedef uint32_t LZ4_u32;
814 #else
815 typedef signed char LZ4_i8;
816 typedef unsigned char LZ4_byte;
817 typedef unsigned short LZ4_u16;
818 typedef unsigned int LZ4_u32;
819 #endif
820 
821 /*! LZ4_stream_t :
822  * Never ever use below internal definitions directly !
823  * These definitions are not API/ABI safe, and may change in future versions.
824  * If you need static allocation, declare or allocate an LZ4_stream_t object.
825  **/
826 
835  /* Implicit padding to ensure structure is aligned */
836 };
837 
838 #define LZ4_STREAM_MINSIZE \
839  ((1UL << (LZ4_MEMORY_USAGE)) + \
840  32) /* static size, for inter-version compatibility */
844 }; /* previously typedef'd to LZ4_stream_t */
845 
846 /*! LZ4_initStream() : v1.9.0+
847  * An LZ4_stream_t structure must be initialized at least once.
848  * This is automatically done when invoking LZ4_createStream(),
849  * but it's not when the structure is simply declared on stack (for example).
850  *
851  * Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t.
852  * It can also initialize any arbitrary buffer of sufficient size,
853  * and will @return a pointer of proper type upon initialization.
854  *
855  * Note : initialization fails if size and alignment conditions are not
856  * respected. In which case, the function will @return NULL.
857  * Note2: An LZ4_stream_t structure guarantees correct alignment and size.
858  * Note3: Before v1.9.0, use LZ4_resetStream() instead
859  **/
860 LZ4LIB_API LZ4_stream_t *LZ4_initStream(void *stateBuffer, size_t size);
861 
862 /*! LZ4_streamDecode_t :
863  * Never ever use below internal definitions directly !
864  * These definitions are not API/ABI safe, and may change in future versions.
865  * If you need static allocation, declare or allocate an LZ4_streamDecode_t
866  *object.
867  **/
868 typedef struct {
869  const LZ4_byte *externalDict;
870  const LZ4_byte *prefixEnd;
871  size_t extDictSize;
872  size_t prefixSize;
874 
875 #define LZ4_STREAMDECODE_MINSIZE 32
879 }; /* previously typedef'd to LZ4_streamDecode_t */
880 
881 /*-************************************
882  * Obsolete Functions
883  **************************************/
884 
885 /*! Deprecation warnings
886  *
887  * Deprecated functions make the compiler generate a warning when invoked.
888  * This is meant to invite users to update their source code.
889  * Should deprecation warnings be a problem, it is generally possible to
890  * disable them, typically with -Wno-deprecated-declarations for gcc or
891  * _CRT_SECURE_NO_WARNINGS in Visual.
892  *
893  * Another method is to define LZ4_DISABLE_DEPRECATE_WARNINGS
894  * before including the header file.
895  */
896 #ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
897 #define LZ4_DEPRECATED(message) /* disable deprecation warnings */
898 #else
899 #if defined(__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
900 #define LZ4_DEPRECATED(message) [[deprecated(message)]]
901 #elif defined(_MSC_VER)
902 #define LZ4_DEPRECATED(message) __declspec(deprecated(message))
903 #elif defined(__clang__) || \
904  (defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 45))
905 #define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
906 #elif defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 31)
907 #define LZ4_DEPRECATED(message) __attribute__((deprecated))
908 #else
909 #pragma message( \
910  "WARNING: LZ4_DEPRECATED needs custom implementation for this compiler")
911 #define LZ4_DEPRECATED(message) /* disabled */
912 #endif
913 #endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
914 
915 /*! Obsolete compression functions (since v1.7.3) */
916 LZ4_DEPRECATED("use LZ4_compress_default() instead")
917 LZ4LIB_API int LZ4_compress(const char *src, char *dest, int srcSize);
919 LZ4LIB_API int LZ4_compress_limitedOutput(const char *src, char *dest,
920  int srcSize, int maxOutputSize);
922 LZ4LIB_API int LZ4_compress_withState(void *state, const char *source,
923  char *dest, int inputSize);
926 int LZ4_compress_limitedOutput_withState(void *state, const char *source,
927  char *dest, int inputSize,
928  int maxOutputSize);
931 int LZ4_compress_continue(LZ4_stream_t *LZ4_streamPtr, const char *source,
932  char *dest, int inputSize);
936  const char *source, char *dest,
937  int inputSize, int maxOutputSize);
938 
939 /*! Obsolete decompression functions (since v1.8.0) */
941 LZ4LIB_API int LZ4_uncompress(const char *source, char *dest, int outputSize);
943 LZ4LIB_API int LZ4_uncompress_unknownOutputSize(const char *source, char *dest,
944  int isize, int maxOutputSize);
945 
946 /* Obsolete streaming functions (since v1.7.0)
947  * degraded functionality; do not use!
948  *
949  * In order to perform streaming compression, these functions depended on data
950  * that is no longer tracked in the state. They have been preserved as well as
951  * possible: using them will still produce a correct output. However, they don't
952  * actually retain any history between compression calls. The compression ratio
953  * achieved will therefore be no better than compressing each chunk
954  * independently.
955  */
957 LZ4LIB_API void *LZ4_create(char *inputBuffer);
961 LZ4LIB_API int LZ4_resetStreamState(void *state, char *inputBuffer);
962 LZ4_DEPRECATED("Use LZ4_saveDict() instead")
964 
965 /*! Obsolete streaming decoding functions (since v1.7.0) */
968 int LZ4_decompress_safe_withPrefix64k(const char *src, char *dst,
969  int compressedSize, int maxDstSize);
971 LZ4LIB_API int LZ4_decompress_fast_withPrefix64k(const char *src, char *dst,
972  int originalSize);
973 
974 /*! Obsolete LZ4_decompress_fast variants (since v1.9.0) :
975  * These functions used to be faster than LZ4_decompress_safe(),
976  * but this is no longer the case. They are now slower.
977  * This is because LZ4_decompress_fast() doesn't know the input size,
978  * and therefore must progress more cautiously into the input buffer to not
979  * read beyond the end of block. On top of that `LZ4_decompress_fast()` is not
980  * protected vs malformed or malicious inputs, making it a security liability.
981  * As a consequence, LZ4_decompress_fast() is strongly discouraged, and
982  * deprecated.
983  *
984  * The last remaining LZ4_decompress_fast() specificity is that
985  * it can decompress a block without knowing its compressed size.
986  * Such functionality can be achieved in a more secure manner
987  * by employing LZ4_decompress_safe_partial().
988  *
989  * Parameters:
990  * @param originalSize is the uncompressed size to regenerate.
991  * `dst` must be already allocated, its size must be >=
992  * 'originalSize' bytes.
993  * @return number of bytes read from source buffer (== compressed size).
994  * The function expects to finish at block's end exactly.
995  * If the source stream is detected malformed, the function stops
996  * decoding and returns a negative result.
997  *
998  * note : LZ4_decompress_fast*() requires originalSize.
999  * Thanks to this information, it never writes past the output buffer.
1000  * However, since it doesn't know its 'src' size, it may read an unknown
1001  * amount of input, past input buffer bounds.
1002  * Also, since match offsets are not validated, match reads from 'src'
1003  * may underflow too.
1004  * These issues never happen if input (compressed) data is correct.
1005  * But they may happen if input data is invalid (error or intentional
1006  * tampering).
1007  * As a consequence, use these functions in trusted environments with
1008  * trusted data **only**.
1009  */
1010 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using "
1012 LZ4LIB_API int LZ4_decompress_fast(const char *src, char *dst,
1013  int originalSize);
1014 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider migrating "
1015  "towards LZ4_decompress_safe_continue() instead. "
1016  "Note that the contract will change (requires block's "
1017  "compressed size, instead of decompressed size)")
1020  const char *src, char *dst, int originalSize);
1021 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using "
1023 LZ4LIB_API int LZ4_decompress_fast_usingDict(const char *src, char *dst,
1024  int originalSize,
1025  const char *dictStart,
1026  int dictSize);
1027 
1028 /*! LZ4_resetStream() :
1029  * An LZ4_stream_t structure must be initialized at least once.
1030  * This is done with LZ4_initStream(), or LZ4_resetStream().
1031  * Consider switching to LZ4_initStream(),
1032  * invoking LZ4_resetStream() will trigger deprecation warnings in the future.
1033  */
1034 LZ4LIB_API void LZ4_resetStream(LZ4_stream_t *streamPtr);
1035 
1036 #endif /* LZ4_H_98237428734687 */
1037 
1038 #if defined(__cplusplus)
1039 }
1040 #endif
int LZ4_compress_fast_extState_fastReset(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition: lz4.c:1720
int LZ4_compress_destSize_extState(void *state, const char *src, char *dst, int *srcSizePtr, int targetDstSize, int acceleration)
Definition: lz4.c:1853
#define LZ4LIB_API
Definition: lz4.h:101
int LZ4_decompress_fast_withPrefix64k(const char *src, char *dst, int originalSize)
#define LZ4_STREAMDECODE_MINSIZE
Definition: lz4.h:874
int LZ4_saveDict(LZ4_stream_t *streamPtr, char *safeBuffer, int maxDictSize)
Definition: lz4.c:2238
int LZ4_decompress_fast_usingDict(const char *src, char *dst, int originalSize, const char *dictStart, int dictSize)
int LZ4_compress_fast(const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition: lz4.c:1786
const char * LZ4_versionString(void)
Definition: lz4.c:875
int LZ4_compress_limitedOutput_continue(LZ4_stream_t *LZ4_streamPtr, const char *source, char *dest, int inputSize, int maxOutputSize)
int LZ4_freeStream(LZ4_stream_t *streamPtr)
Definition: lz4.c:1946
int LZ4_compress_fast_extState(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition: lz4.c:1666
LZ4_stream_t * LZ4_createStream(void)
Definition: lz4.c:1892
LZ4_streamDecode_t * LZ4_createStreamDecode(void)
int LZ4_compressBound(int inputSize)
Definition: lz4.c:879
int LZ4_decompress_safe_partial(const char *src, char *dst, int srcSize, int targetOutputSize, int dstCapacity)
void * LZ4_create(char *inputBuffer)
int LZ4_compress_withState(void *state, const char *source, char *dest, int inputSize)
int LZ4_decoderRingBufferSize(int maxBlockSize)
LZ4_stream_t * LZ4_initStream(void *stateBuffer, size_t size)
Definition: lz4.c:1917
int LZ4_compress_fast_continue(LZ4_stream_t *streamPtr, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition: lz4.c:2087
int LZ4_compress_destSize(const char *src, char *dst, int *srcSizePtr, int targetDstSize)
Definition: lz4.c:1865
int LZ4_sizeofState(void)
Definition: lz4.c:883
int LZ4_compress(const char *src, char *dest, int srcSize)
int LZ4_decompress_safe_partial_usingDict(const char *src, char *dst, int compressedSize, int targetOutputSize, int maxOutputSize, const char *dictStart, int dictSize)
void LZ4_resetStream_fast(LZ4_stream_t *streamPtr)
Definition: lz4.c:1940
#define LZ4_HASH_SIZE_U32
Definition: lz4.h:803
int LZ4_uncompress(const char *source, char *dest, int outputSize)
#define LZ4_STREAM_MINSIZE
Definition: lz4.h:837
int LZ4_decompress_safe_withPrefix64k(const char *src, char *dst, int compressedSize, int maxDstSize)
void LZ4_resetStream(LZ4_stream_t *streamPtr)
Definition: lz4.c:1934
int LZ4_decompress_fast(const char *src, char *dst, int originalSize)
int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize, int maxOutputSize)
int LZ4_compress_limitedOutput(const char *src, char *dest, int srcSize, int maxOutputSize)
int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary, int dictSize)
Definition: lz4.c:2024
char * LZ4_slideInputBuffer(void *state)
int LZ4_sizeofStreamState(void)
unsigned short LZ4_u16
Definition: lz4.h:816
int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, const char *dictionary, int dictSize)
int LZ4_versionNumber(void)
Definition: lz4.c:871
int LZ4_compress_default(const char *src, char *dst, int srcSize, int dstCapacity)
Definition: lz4.c:1808
int LZ4_compress_limitedOutput_withState(void *state, const char *source, char *dest, int inputSize, int maxOutputSize)
int LZ4_loadDictSlow(LZ4_stream_t *streamPtr, const char *dictionary, int dictSize)
Definition: lz4.c:2029
signed char LZ4_i8
Definition: lz4.h:814
int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *src, char *dst, int srcSize, int dstCapacity)
unsigned char LZ4_byte
Definition: lz4.h:815
int LZ4_resetStreamState(void *state, char *inputBuffer)
int LZ4_decompress_safe(const char *src, char *dst, int compressedSize, int dstCapacity)
void LZ4_attach_dictionary(LZ4_stream_t *workingStream, const LZ4_stream_t *dictionaryStream)
Definition: lz4.c:2035
int LZ4_compress_continue(LZ4_stream_t *LZ4_streamPtr, const char *source, char *dest, int inputSize)
int LZ4_decompress_safe_usingDict(const char *src, char *dst, int srcSize, int dstCapacity, const char *dictStart, int dictSize)
int LZ4_decompress_fast_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *src, char *dst, int originalSize)
unsigned int LZ4_u32
Definition: lz4.h:817
#define LZ4_DEPRECATED(message)
Definition: lz4.h:910
int LZ4_freeStreamDecode(LZ4_streamDecode_t *LZ4_stream)
struct state state
Definition: parser.c:103
const LZ4_stream_t_internal * dictCtx
Definition: lz4.h:830
LZ4_u32 hashTable[(1<<(14 - 2))]
Definition: lz4.h:828
LZ4_u32 tableType
Definition: lz4.h:832
LZ4_u32 currentOffset
Definition: lz4.h:831
const LZ4_byte * dictionary
Definition: lz4.h:829
LZ4_u32 dictSize
Definition: lz4.h:833
LZ4_streamDecode_t_internal internal_donotuse
Definition: lz4.h:877
char minStateSize[32]
Definition: lz4.h:876
LZ4_stream_t_internal internal_donotuse
Definition: lz4.h:842
char minStateSize[((1UL<<(14))+32)]
Definition: lz4.h:841