GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-b4e4cb0fe9
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. Default value is 14, for
167  * 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). It also runs faster, so it's a recommended
194  * setting. If the function cannot compress 'src' into a more limited 'dst'
195  * budget, compression stops *immediately*, and the function result is zero. In
196  * which case, 'dst' content is undefined (invalid). srcSize : max supported
197  * value is LZ4_MAX_INPUT_SIZE. dstCapacity : size of buffer 'dst' (which must
198  * be already allocated)
199  * @return : the number of bytes written into buffer 'dst' (necessarily <=
200  * dstCapacity) or 0 if compression fails Note : This function is protected
201  * against buffer overflow scenarios (never writes outside 'dst' buffer, nor
202  * read outside 'source' buffer).
203  */
204 LZ4LIB_API int LZ4_compress_default(const char *src, char *dst, int srcSize,
205  int dstCapacity);
206 
207 /*! LZ4_decompress_safe() :
208  * @compressedSize : is the exact complete size of the compressed block.
209  * @dstCapacity : is the size of destination buffer (which must be already
210  * allocated), presumed an upper bound of decompressed size.
211  * @return : the number of bytes decompressed into destination buffer
212  * (necessarily <= dstCapacity) If destination buffer is not large enough,
213  * decoding will stop and output an error code (negative value). If the source
214  * stream is detected malformed, the function will stop decoding and return a
215  * negative result. Note 1 : This function is protected against malicious data
216  * packets : it will never writes outside 'dst' buffer, nor read outside
217  * 'source' buffer, even if the compressed block is maliciously modified to
218  * order the decoder to do these actions. In such case, the decoder stops
219  * immediately, and considers the compressed block malformed. Note 2 :
220  * compressedSize and dstCapacity must be provided to the function, the
221  * compressed block does not contain them. The implementation is free to send /
222  * store / derive this information in whichever way is most beneficial. If there
223  * is a need for a different format which bundles together both compressed data
224  * and its metadata, consider looking at lz4frame.h instead.
225  */
226 LZ4LIB_API int LZ4_decompress_safe(const char *src, char *dst,
227  int compressedSize, int dstCapacity);
228 
229 /*-************************************
230  * Advanced Functions
231  **************************************/
232 #define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
233 #define LZ4_COMPRESSBOUND(isize) \
234  ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE \
235  ? 0 \
236  : (isize) + ((isize) / 255) + 16)
237 
238 /*! LZ4_compressBound() :
239  Provides the maximum size that LZ4 compression may output in a "worst case"
240  scenario (input data not compressible) This function is primarily useful for
241  memory allocation purposes (destination buffer size). Macro
242  LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack
243  memory allocation for example). Note that LZ4_compress_default() compresses
244  faster when dstCapacity is >= LZ4_compressBound(srcSize) inputSize : max
245  supported value is LZ4_MAX_INPUT_SIZE return : maximum output size in a
246  "worst case" scenario or 0, if input size is incorrect (too large or
247  negative)
248 */
249 LZ4LIB_API int LZ4_compressBound(int inputSize);
250 
251 /*! LZ4_compress_fast() :
252  Same as LZ4_compress_default(), but allows selection of "acceleration"
253  factor. The larger the acceleration value, the faster the algorithm, but also
254  the lesser the compression. It's a trade-off. It can be fine tuned, with each
255  successive value providing roughly +~3% to speed. An acceleration value of
256  "1" is the same as regular LZ4_compress_default() Values <= 0 will be
257  replaced by LZ4_ACCELERATION_DEFAULT (currently == 1, see lz4.c). Values >
258  LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX (currently ==
259  65537, see lz4.c).
260 */
261 LZ4LIB_API int LZ4_compress_fast(const char *src, char *dst, int srcSize,
262  int dstCapacity, int acceleration);
263 
264 /*! LZ4_compress_fast_extState() :
265  * Same as LZ4_compress_fast(), using an externally allocated memory space for
266  * its state. Use LZ4_sizeofState() to know how much memory must be allocated,
267  * and allocate it on 8-bytes boundaries (using `malloc()` typically).
268  * Then, provide this buffer as `void* state` to compression function.
269  */
270 LZ4LIB_API int LZ4_sizeofState(void);
271 LZ4LIB_API int LZ4_compress_fast_extState(void *state, const char *src,
272  char *dst, int srcSize,
273  int dstCapacity, int acceleration);
274 
275 /*! LZ4_compress_destSize() :
276  * Reverse the logic : compresses as much data as possible from 'src' buffer
277  * into already allocated buffer 'dst', of size >= 'dstCapacity'.
278  * This function either compresses the entire 'src' content into 'dst' if it's
279  * large enough, or fill 'dst' buffer completely with as much data as possible
280  * from 'src'. note: acceleration parameter is fixed to "default".
281  *
282  * *srcSizePtr : in+out parameter. Initially contains size of input.
283  * Will be modified to indicate how many bytes where read from
284  * 'src' to fill 'dst'. New value is necessarily <= input value.
285  * @return : Nb bytes written into 'dst' (necessarily <= dstCapacity)
286  * or 0 if compression fails.
287  *
288  * Note : from v1.8.2 to v1.9.1, this function had a bug (fixed in v1.9.2+):
289  * the produced compressed content could, in specific circumstances,
290  * require to be decompressed into a destination buffer larger
291  * by at least 1 byte than the content to decompress.
292  * If an application uses `LZ4_compress_destSize()`,
293  * it's highly recommended to update liblz4 to v1.9.2 or better.
294  * If this can't be done or ensured,
295  * the receiving decompression function should provide
296  * a dstCapacity which is > decompressedSize, by at least 1 byte.
297  * See https://github.com/lz4/lz4/issues/859 for details
298  */
299 LZ4LIB_API int LZ4_compress_destSize(const char *src, char *dst,
300  int *srcSizePtr, int targetDstSize);
301 
302 /*! LZ4_decompress_safe_partial() :
303  * Decompress an LZ4 compressed block, of size 'srcSize' at position 'src',
304  * into destination buffer 'dst' of size 'dstCapacity'.
305  * Up to 'targetOutputSize' bytes will be decoded.
306  * The function stops decoding on reaching this objective.
307  * This can be useful to boost performance
308  * whenever only the beginning of a block is required.
309  *
310  * @return : the number of bytes decoded in `dst` (necessarily <=
311  * targetOutputSize) If source stream is detected malformed, function returns a
312  * negative result.
313  *
314  * Note 1 : @return can be < targetOutputSize, if compressed block contains
315  * less data.
316  *
317  * Note 2 : targetOutputSize must be <= dstCapacity
318  *
319  * Note 3 : this function effectively stops decoding on reaching
320  * targetOutputSize, so dstCapacity is kind of redundant. This is because in
321  * older versions of this function, decoding operation would still write
322  * complete sequences. Therefore, there was no guarantee that it would stop
323  * writing at exactly targetOutputSize, it could write more bytes, though only
324  * up to dstCapacity. Some "margin" used to be required for this operation to
325  * work properly. Thankfully, this is no longer necessary. The function
326  * nonetheless keeps the same signature, in an effort to preserve API
327  * compatibility.
328  *
329  * Note 4 : If srcSize is the exact size of the block,
330  * then targetOutputSize can be any value,
331  * including larger than the block's decompressed size.
332  * The function will, at most, generate block's decompressed size.
333  *
334  * Note 5 : If srcSize is _larger_ than block's compressed size,
335  * then targetOutputSize **MUST** be <= block's decompressed size.
336  * Otherwise, *silent corruption will occur*.
337  */
338 LZ4LIB_API int LZ4_decompress_safe_partial(const char *src, char *dst,
339  int srcSize, int targetOutputSize,
340  int dstCapacity);
341 
342 /*-*********************************************
343  * Streaming Compression Functions
344  ***********************************************/
345 typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
346 
347 /*!
348  Note about RC_INVOKED
349 
350  - RC_INVOKED is predefined symbol of rc.exe (the resource compiler which is
351  part of MSVC/Visual Studio).
352  https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros
353 
354  - Since rc.exe is a legacy compiler, it truncates long symbol (> 30 chars)
355  and reports warning "RC4011: identifier truncated".
356 
357  - To eliminate the warning, we surround long preprocessor symbol with
358  "#if !defined(RC_INVOKED) ... #endif" block that means
359  "skip this block when rc.exe is trying to read it".
360 */
361 #if !defined( \
362  RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros \
363  */
364 #if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
366 LZ4LIB_API int LZ4_freeStream(LZ4_stream_t *streamPtr);
367 #endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
368 #endif
369 
370 /*! LZ4_resetStream_fast() : v1.9.0+
371  * Use this to prepare an LZ4_stream_t for a new chain of dependent blocks
372  * (e.g., LZ4_compress_fast_continue()).
373  *
374  * An LZ4_stream_t must be initialized once before usage.
375  * This is automatically done when created by LZ4_createStream().
376  * However, should the LZ4_stream_t be simply declared on stack (for example),
377  * it's necessary to initialize it first, using LZ4_initStream().
378  *
379  * After init, start any new stream with LZ4_resetStream_fast().
380  * A same LZ4_stream_t can be re-used multiple times consecutively
381  * and compress multiple streams,
382  * provided that it starts each new stream with LZ4_resetStream_fast().
383  *
384  * LZ4_resetStream_fast() is much faster than LZ4_initStream(),
385  * but is not compatible with memory regions containing garbage data.
386  *
387  * Note: it's only useful to call LZ4_resetStream_fast()
388  * in the context of streaming compression.
389  * The *extState* functions perform their own resets.
390  * Invoking LZ4_resetStream_fast() before is redundant, and even
391  * counterproductive.
392  */
394 
395 /*! LZ4_loadDict() :
396  * Use this function to reference a static dictionary into LZ4_stream_t.
397  * The dictionary must remain available during compression.
398  * LZ4_loadDict() triggers a reset, so any previous data will be forgotten.
399  * The same dictionary will have to be loaded on decompression side for
400  * successful decoding. Dictionary are useful for better compression of small
401  * data (KB range). While LZ4 itself accepts any input as dictionary, dictionary
402  * efficiency is also a topic. When in doubt, employ the Zstandard's Dictionary
403  * Builder. Loading a size of 0 is allowed, and is the same as reset.
404  * @return : loaded dictionary size, in bytes (note: only the last 64 KB are
405  * loaded)
406  */
407 LZ4LIB_API int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary,
408  int dictSize);
409 
410 /*! LZ4_loadDictSlow() : v1.10.0+
411  * Same as LZ4_loadDict(),
412  * but uses a bit more cpu to reference the dictionary content more thoroughly.
413  * This is expected to slightly improve compression ratio.
414  * The extra-cpu cost is likely worth it if the dictionary is re-used across
415  * multiple sessions.
416  * @return : loaded dictionary size, in bytes (note: only the last 64 KB are
417  * loaded)
418  */
419 LZ4LIB_API int LZ4_loadDictSlow(LZ4_stream_t *streamPtr, const char *dictionary,
420  int dictSize);
421 
422 /*! LZ4_attach_dictionary() : stable since v1.10.0
423  *
424  * This allows efficient re-use of a static dictionary multiple times.
425  *
426  * Rather than re-loading the dictionary buffer into a working context before
427  * each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
428  * working LZ4_stream_t, this function introduces a no-copy setup mechanism,
429  * in which the working stream references @dictionaryStream in-place.
430  *
431  * Several assumptions are made about the state of @dictionaryStream.
432  * Currently, only states which have been prepared by LZ4_loadDict() or
433  * LZ4_loadDictSlow() should be expected to work.
434  *
435  * Alternatively, the provided @dictionaryStream may be NULL,
436  * in which case any existing dictionary stream is unset.
437  *
438  * If a dictionary is provided, it replaces any pre-existing stream history.
439  * The dictionary contents are the only history that can be referenced and
440  * logically immediately precede the data compressed in the first subsequent
441  * compression call.
442  *
443  * The dictionary will only remain attached to the working stream through the
444  * first compression call, at the end of which it is cleared.
445  * @dictionaryStream stream (and source buffer) must remain in-place /
446  * accessible / unchanged through the completion of the compression session.
447  *
448  * Note: there is no equivalent LZ4_attach_*() method on the decompression side
449  * because there is no initialization cost, hence no need to share the cost
450  * across multiple sessions. To decompress LZ4 blocks using dictionary, attached
451  * or not, just employ the regular LZ4_setStreamDecode() for streaming, or the
452  * stateless LZ4_decompress_safe_usingDict() for one-shot decompression.
453  */
454 LZ4LIB_API void LZ4_attach_dictionary(LZ4_stream_t *workingStream,
455  const LZ4_stream_t *dictionaryStream);
456 
457 /*! LZ4_compress_fast_continue() :
458  * Compress 'src' content using data from previously compressed blocks, for
459  * better compression ratio. 'dst' buffer must be already allocated. If
460  * dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to
461  * succeed, and runs faster.
462  *
463  * @return : size of compressed block
464  * or 0 if there is an error (typically, cannot fit into 'dst').
465  *
466  * Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new
467  * block. Each block has precise boundaries. Each block must be decompressed
468  * separately, calling LZ4_decompress_*() with relevant metadata. It's not
469  * possible to append blocks together and expect a single invocation of
470  * LZ4_decompress_*() to decompress them together.
471  *
472  * Note 2 : The previous 64KB of source data is __assumed__ to remain present,
473  * unmodified, at same address in memory !
474  *
475  * Note 3 : When input is structured as a double-buffer, each buffer can have
476  * any size, including < 64 KB. Make sure that buffers are separated, by at
477  * least one byte. This construction ensures that each block only depends on
478  * previous block.
479  *
480  * Note 4 : If input buffer is a ring-buffer, it can have any size, including <
481  * 64 KB.
482  *
483  * Note 5 : After an error, the stream status is undefined (invalid), it can
484  * only be reset or freed.
485  */
487  const char *src, char *dst,
488  int srcSize, int dstCapacity,
489  int acceleration);
490 
491 /*! LZ4_saveDict() :
492  * If last 64KB data cannot be guaranteed to remain available at its current
493  * memory location, save it into a safer place (char* safeBuffer). This is
494  * schematically equivalent to a memcpy() followed by LZ4_loadDict(), but is
495  * much faster, because LZ4_saveDict() doesn't need to rebuild tables.
496  * @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0
497  * if error.
498  */
499 LZ4LIB_API int LZ4_saveDict(LZ4_stream_t *streamPtr, char *safeBuffer,
500  int maxDictSize);
501 
502 /*-**********************************************
503  * Streaming Decompression Functions
504  * Bufferless synchronous API
505  ************************************************/
506 typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
507 
508 /*! LZ4_createStreamDecode() and LZ4_freeStreamDecode() :
509  * creation / destruction of streaming decompression tracking context.
510  * A tracking context can be re-used multiple times.
511  */
512 #if !defined( \
513  RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros \
514  */
515 #if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
518 #endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
519 #endif
520 
521 /*! LZ4_setStreamDecode() :
522  * An LZ4_streamDecode_t context can be allocated once and re-used multiple
523  * times. Use this function to start decompression of a new stream of blocks. A
524  * dictionary can optionally be set. Use NULL or size 0 for a reset order.
525  * Dictionary is presumed stable : it must remain accessible and unmodified
526  * during next decompression.
527  * @return : 1 if OK, 0 if error
528  */
530  const char *dictionary, int dictSize);
531 
532 /*! LZ4_decoderRingBufferSize() : v1.8.2+
533  * Note : in a ring buffer scenario (optional),
534  * blocks are presumed decompressed next to each other
535  * up to the moment there is not enough remaining space for next block
536  * (remainingSize < maxBlockSize), at which stage it resumes from beginning of
537  * ring buffer. When setting such a ring buffer for streaming decompression,
538  * provides the minimum size of this ring buffer
539  * to be compatible with any source respecting maxBlockSize condition.
540  * @return : minimum ring buffer size,
541  * or 0 if there is an error (invalid maxBlockSize).
542  */
543 LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
544 #define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) \
545  (65536 + 14 + \
546  (maxBlockSize)) /* for static allocation; maxBlockSize presumed valid */
547 
548 /*! LZ4_decompress_safe_continue() :
549  * This decoding function allows decompression of consecutive blocks in
550  * "streaming" mode. The difference with the usual independent blocks is that
551  * new blocks are allowed to find references into former blocks.
552  * A block is an unsplittable entity, and must be presented entirely to the
553  * decompression function. LZ4_decompress_safe_continue() only accepts one block
554  * at a time. It's modeled after `LZ4_decompress_safe()` and behaves similarly.
555  *
556  * @LZ4_streamDecode : decompression state, tracking the position in memory of
557  * past data
558  * @compressedSize : exact complete size of one compressed block.
559  * @dstCapacity : size of destination buffer (which must be already allocated),
560  * must be an upper bound of decompressed size.
561  * @return : number of bytes decompressed into destination buffer (necessarily
562  * <= dstCapacity) If destination buffer is not large enough, decoding will stop
563  * and output an error code (negative value). If the source stream is detected
564  * malformed, the function will stop decoding and return a negative result.
565  *
566  * The last 64KB of previously decoded data *must* remain available and
567  * unmodified at the memory position where they were previously decoded. If less
568  * than 64KB of data has been decoded, all the data must be present.
569  *
570  * Special : if decompression side sets a ring buffer, it must respect one of
571  * the following conditions :
572  * - Decompression buffer size is _at least_
573  * LZ4_decoderRingBufferSize(maxBlockSize). maxBlockSize is the maximum size of
574  * any single block. It can have any value > 16 bytes. In which case, encoding
575  * and decoding buffers do not need to be synchronized. Actually, data can be
576  * produced by any source compliant with LZ4 format specification, and
577  * respecting maxBlockSize.
578  * - Synchronized mode :
579  * Decompression buffer size is _exactly_ the same as compression buffer
580  * size, and follows exactly same update rule (block boundaries at same
581  * positions), and decoding function is provided with exact decompressed size of
582  * each block (exception for last block of the stream), _then_ decoding &
583  * encoding ring buffer can have any size, including small ones ( < 64 KB).
584  * - Decompression buffer is larger than encoding buffer, by a minimum of
585  * maxBlockSize more bytes. In which case, encoding and decoding buffers do not
586  * need to be synchronized, and encoding ring buffer can have any size,
587  * including small ones ( < 64 KB).
588  *
589  * Whenever these conditions are not possible,
590  * save the last 64KB of decoded data into a safe buffer where it can't be
591  * modified during decompression, then indicate where this data is saved using
592  * LZ4_setStreamDecode(), before decompressing next block.
593  */
594 LZ4LIB_API int
596  const char *src, char *dst, int srcSize,
597  int dstCapacity);
598 
599 /*! LZ4_decompress_safe_usingDict() :
600  * Works the same as
601  * a combination of LZ4_setStreamDecode() followed by
602  * LZ4_decompress_safe_continue() However, it's stateless: it doesn't need any
603  * LZ4_streamDecode_t state. Dictionary is presumed stable : it must remain
604  * accessible and unmodified during decompression. Performance tip :
605  * Decompression speed can be substantially increased when dst == dictStart +
606  * dictSize.
607  */
608 LZ4LIB_API int LZ4_decompress_safe_usingDict(const char *src, char *dst,
609  int srcSize, int dstCapacity,
610  const char *dictStart,
611  int dictSize);
612 
613 /*! LZ4_decompress_safe_partial_usingDict() :
614  * Behaves the same as LZ4_decompress_safe_partial()
615  * with the added ability to specify a memory segment for past data.
616  * Performance tip : Decompression speed can be substantially increased
617  * when dst == dictStart + dictSize.
618  */
620  const char *src, char *dst, int compressedSize, int targetOutputSize,
621  int maxOutputSize, const char *dictStart, int dictSize);
622 
623 #endif /* LZ4_H_2983827168210 */
624 
625 /*^*************************************
626  * !!!!!! STATIC LINKING ONLY !!!!!!
627  ***************************************/
628 
629 /*-****************************************************************************
630  * Experimental section
631  *
632  * Symbols declared in this section must be considered unstable. Their
633  * signatures or semantics may change, or they may be removed altogether in the
634  * future. They are therefore only safe to depend on when the caller is
635  * statically linked against the library.
636  *
637  * To protect against unsafe usage, not only are the declarations guarded,
638  * the definitions are hidden by default
639  * when building LZ4 as a shared/dynamic library.
640  *
641  * In order to access these declarations,
642  * define LZ4_STATIC_LINKING_ONLY in your application
643  * before including LZ4's headers.
644  *
645  * In order to make their implementations accessible dynamically, you must
646  * define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library.
647  ******************************************************************************/
648 
649 #ifdef LZ4_STATIC_LINKING_ONLY
650 
651 #ifndef LZ4_STATIC_3504398509
652 #define LZ4_STATIC_3504398509
653 
654 #ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
655 #define LZ4LIB_STATIC_API LZ4LIB_API
656 #else
657 #define LZ4LIB_STATIC_API
658 #endif
659 
660 /*! LZ4_compress_fast_extState_fastReset() :
661  * A variant of LZ4_compress_fast_extState().
662  *
663  * Using this variant avoids an expensive initialization step.
664  * It is only safe to call if the state buffer is known to be correctly
665  * initialized already (see above comment on LZ4_resetStream_fast() for a
666  * definition of "correctly initialized"). From a high level, the difference is
667  * that this function initializes the provided state with a call to something
668  * like LZ4_resetStream_fast() while LZ4_compress_fast_extState() starts with a
669  * call to LZ4_resetStream().
670  */
671 LZ4LIB_STATIC_API int
672 LZ4_compress_fast_extState_fastReset(void *state, const char *src, char *dst,
673  int srcSize, int dstCapacity,
674  int acceleration);
675 
676 /*! LZ4_compress_destSize_extState() : introduced in v1.10.0
677  * Same as LZ4_compress_destSize(), but using an externally allocated state.
678  * Also: exposes @acceleration
679  */
680 int LZ4_compress_destSize_extState(void *state, const char *src, char *dst,
681  int *srcSizePtr, int targetDstSize,
682  int acceleration);
683 
684 /*! In-place compression and decompression
685  *
686  * It's possible to have input and output sharing the same buffer,
687  * for highly constrained memory environments.
688  * In both cases, it requires input to lay at the end of the buffer,
689  * and decompression to start at beginning of the buffer.
690  * Buffer size must feature some margin, hence be larger than final size.
691  *
692  * |<------------------------buffer--------------------------------->|
693  * |<-----------compressed data--------->|
694  * |<-----------decompressed size------------------>|
695  * |<----margin---->|
696  *
697  * This technique is more useful for decompression,
698  * since decompressed size is typically larger,
699  * and margin is short.
700  *
701  * In-place decompression will work inside any buffer
702  * which size is >= LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize).
703  * This presumes that decompressedSize > compressedSize.
704  * Otherwise, it means compression actually expanded data,
705  * and it would be more efficient to store such data with a flag indicating it's
706  * not compressed. This can happen when data is not compressible (already
707  * compressed, or encrypted).
708  *
709  * For in-place compression, margin is larger, as it must be able to cope with
710  * both history preservation, requiring input data to remain unmodified up to
711  * LZ4_DISTANCE_MAX, and data expansion, which can happen when input is not
712  * compressible. As a consequence, buffer size requirements are much higher, and
713  * memory savings offered by in-place compression are more limited.
714  *
715  * There are ways to limit this cost for compression :
716  * - Reduce history size, by modifying LZ4_DISTANCE_MAX.
717  * Note that it is a compile-time constant, so all compressions will apply
718  * this limit. Lower values will reduce compression ratio, except when
719  * input_size < LZ4_DISTANCE_MAX, so it's a reasonable trick when inputs are
720  * known to be small.
721  * - Require the compressor to deliver a "maximum compressed size".
722  * This is the `dstCapacity` parameter in `LZ4_compress*()`.
723  * When this size is < LZ4_COMPRESSBOUND(inputSize), then compression can
724  * fail, in which case, the return code will be 0 (zero). The caller must be
725  * ready for these cases to happen, and typically design a backup scheme to send
726  * data uncompressed. The combination of both techniques can significantly
727  * reduce the amount of margin required for in-place compression.
728  *
729  * In-place compression can work in any buffer
730  * which size is >= (maxCompressedSize)
731  * with maxCompressedSize == LZ4_COMPRESSBOUND(srcSize) for guaranteed
732  * compression success. LZ4_COMPRESS_INPLACE_BUFFER_SIZE() depends on both
733  * maxCompressedSize and LZ4_DISTANCE_MAX, so it's possible to reduce memory
734  * requirements by playing with them.
735  */
736 
737 #define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) \
738  (((compressedSize) >> 8) + 32)
739 #define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize) \
740  ((decompressedSize) + \
741  LZ4_DECOMPRESS_INPLACE_MARGIN( \
742  decompressedSize)) /**< note: presumes that compressedSize < \
743  decompressedSize. note2: margin is \
744  overestimated a bit, since it could use \
745  compressedSize instead */
746 
747 #ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at \
748  compile time */
749 #define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
750 #endif
751 
752 #define LZ4_COMPRESS_INPLACE_MARGIN \
753  (LZ4_DISTANCE_MAX + 32) /* LZ4_DISTANCE_MAX can be safely replaced by \
754  srcSize when it's smaller */
755 #define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize) \
756  ((maxCompressedSize) + \
757  LZ4_COMPRESS_INPLACE_MARGIN) /**< maxCompressedSize is generally \
758  LZ4_COMPRESSBOUND(inputSize), but can be \
759  set to any lower value, with the risk \
760  that compression can fail (return code \
761  0(zero)) */
762 
763 #endif /* LZ4_STATIC_3504398509 */
764 #endif /* LZ4_STATIC_LINKING_ONLY */
765 
766 #ifndef LZ4_H_98237428734687
767 #define LZ4_H_98237428734687
768 
769 /*-************************************************************
770  * Private Definitions
771  **************************************************************
772  * Do not use these definitions directly.
773  * They are only exposed to allow static allocation of `LZ4_stream_t` and
774  *`LZ4_streamDecode_t`. Accessing members will expose user code to API and/or
775  *ABI break in future versions of the library.
776  **************************************************************/
777 #define LZ4_HASHLOG (LZ4_MEMORY_USAGE - 2)
778 #define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
779 #define LZ4_HASH_SIZE_U32 \
780  (1 << LZ4_HASHLOG) /* required as macro for static allocation */
781 
782 #if defined(__cplusplus) || \
783  (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
784 #include <stdint.h>
785 typedef int8_t LZ4_i8;
786 typedef uint8_t LZ4_byte;
787 typedef uint16_t LZ4_u16;
788 typedef uint32_t LZ4_u32;
789 #else
790 typedef signed char LZ4_i8;
791 typedef unsigned char LZ4_byte;
792 typedef unsigned short LZ4_u16;
793 typedef unsigned int LZ4_u32;
794 #endif
795 
796 /*! LZ4_stream_t :
797  * Never ever use below internal definitions directly !
798  * These definitions are not API/ABI safe, and may change in future versions.
799  * If you need static allocation, declare or allocate an LZ4_stream_t object.
800  **/
801 
810  /* Implicit padding to ensure structure is aligned */
811 };
812 
813 #define LZ4_STREAM_MINSIZE \
814  ((1UL << (LZ4_MEMORY_USAGE)) + \
815  32) /* static size, for inter-version compatibility */
819 }; /* previously typedef'd to LZ4_stream_t */
820 
821 /*! LZ4_initStream() : v1.9.0+
822  * An LZ4_stream_t structure must be initialized at least once.
823  * This is automatically done when invoking LZ4_createStream(),
824  * but it's not when the structure is simply declared on stack (for example).
825  *
826  * Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t.
827  * It can also initialize any arbitrary buffer of sufficient size,
828  * and will @return a pointer of proper type upon initialization.
829  *
830  * Note : initialization fails if size and alignment conditions are not
831  *respected. In which case, the function will @return NULL. Note2: An
832  *LZ4_stream_t structure guarantees correct alignment and size. Note3: Before
833  *v1.9.0, use LZ4_resetStream() instead
834  **/
835 LZ4LIB_API LZ4_stream_t *LZ4_initStream(void *stateBuffer, size_t size);
836 
837 /*! LZ4_streamDecode_t :
838  * Never ever use below internal definitions directly !
839  * These definitions are not API/ABI safe, and may change in future versions.
840  * If you need static allocation, declare or allocate an LZ4_streamDecode_t
841  *object.
842  **/
843 typedef struct {
844  const LZ4_byte *externalDict;
845  const LZ4_byte *prefixEnd;
846  size_t extDictSize;
847  size_t prefixSize;
849 
850 #define LZ4_STREAMDECODE_MINSIZE 32
854 }; /* previously typedef'd to LZ4_streamDecode_t */
855 
856 /*-************************************
857  * Obsolete Functions
858  **************************************/
859 
860 /*! Deprecation warnings
861  *
862  * Deprecated functions make the compiler generate a warning when invoked.
863  * This is meant to invite users to update their source code.
864  * Should deprecation warnings be a problem, it is generally possible to
865  * disable them, typically with -Wno-deprecated-declarations for gcc or
866  * _CRT_SECURE_NO_WARNINGS in Visual.
867  *
868  * Another method is to define LZ4_DISABLE_DEPRECATE_WARNINGS
869  * before including the header file.
870  */
871 #ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
872 #define LZ4_DEPRECATED(message) /* disable deprecation warnings */
873 #else
874 #if defined(__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
875 #define LZ4_DEPRECATED(message) [[deprecated(message)]]
876 #elif defined(_MSC_VER)
877 #define LZ4_DEPRECATED(message) __declspec(deprecated(message))
878 #elif defined(__clang__) || \
879  (defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 45))
880 #define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
881 #elif defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 31)
882 #define LZ4_DEPRECATED(message) __attribute__((deprecated))
883 #else
884 #pragma message( \
885  "WARNING: LZ4_DEPRECATED needs custom implementation for this compiler")
886 #define LZ4_DEPRECATED(message) /* disabled */
887 #endif
888 #endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
889 
890 /*! Obsolete compression functions (since v1.7.3) */
891 LZ4_DEPRECATED("use LZ4_compress_default() instead")
892 LZ4LIB_API int LZ4_compress(const char *src, char *dest, int srcSize);
893 LZ4_DEPRECATED("use LZ4_compress_default() instead")
894 LZ4LIB_API int LZ4_compress_limitedOutput(const char *src, char *dest,
895  int srcSize, int maxOutputSize);
897 LZ4LIB_API int LZ4_compress_withState(void *state, const char *source,
898  char *dest, int inputSize);
901 int LZ4_compress_limitedOutput_withState(void *state, const char *source,
902  char *dest, int inputSize,
903  int maxOutputSize);
906 int LZ4_compress_continue(LZ4_stream_t *LZ4_streamPtr, const char *source,
907  char *dest, int inputSize);
911  const char *source, char *dest,
912  int inputSize, int maxOutputSize);
913 
914 /*! Obsolete decompression functions (since v1.8.0) */
915 LZ4_DEPRECATED("use LZ4_decompress_fast() instead")
916 LZ4LIB_API int LZ4_uncompress(const char *source, char *dest, int outputSize);
917 LZ4_DEPRECATED("use LZ4_decompress_safe() instead")
918 LZ4LIB_API int LZ4_uncompress_unknownOutputSize(const char *source, char *dest,
919  int isize, int maxOutputSize);
920 
921 /* Obsolete streaming functions (since v1.7.0)
922  * degraded functionality; do not use!
923  *
924  * In order to perform streaming compression, these functions depended on data
925  * that is no longer tracked in the state. They have been preserved as well as
926  * possible: using them will still produce a correct output. However, they don't
927  * actually retain any history between compression calls. The compression ratio
928  * achieved will therefore be no better than compressing each chunk
929  * independently.
930  */
931 LZ4_DEPRECATED("Use LZ4_createStream() instead")
932 LZ4LIB_API void *LZ4_create(char *inputBuffer);
933 LZ4_DEPRECATED("Use LZ4_createStream() instead")
935 LZ4_DEPRECATED("Use LZ4_resetStream() instead")
936 LZ4LIB_API int LZ4_resetStreamState(void *state, char *inputBuffer);
937 LZ4_DEPRECATED("Use LZ4_saveDict() instead")
939 
940 /*! Obsolete streaming decoding functions (since v1.7.0) */
943 int LZ4_decompress_safe_withPrefix64k(const char *src, char *dst,
944  int compressedSize, int maxDstSize);
946 LZ4LIB_API int LZ4_decompress_fast_withPrefix64k(const char *src, char *dst,
947  int originalSize);
948 
949 /*! Obsolete LZ4_decompress_fast variants (since v1.9.0) :
950  * These functions used to be faster than LZ4_decompress_safe(),
951  * but this is no longer the case. They are now slower.
952  * This is because LZ4_decompress_fast() doesn't know the input size,
953  * and therefore must progress more cautiously into the input buffer to not
954  * read beyond the end of block. On top of that `LZ4_decompress_fast()` is not
955  * protected vs malformed or malicious inputs, making it a security liability.
956  * As a consequence, LZ4_decompress_fast() is strongly discouraged, and
957  * deprecated.
958  *
959  * The last remaining LZ4_decompress_fast() specificity is that
960  * it can decompress a block without knowing its compressed size.
961  * Such functionality can be achieved in a more secure manner
962  * by employing LZ4_decompress_safe_partial().
963  *
964  * Parameters:
965  * originalSize : is the uncompressed size to regenerate.
966  * `dst` must be already allocated, its size must be >=
967  * 'originalSize' bytes.
968  * @return : number of bytes read from source buffer (== compressed size).
969  * The function expects to finish at block's end exactly.
970  * If the source stream is detected malformed, the function stops
971  * decoding and returns a negative result. note : LZ4_decompress_fast*()
972  * requires originalSize. Thanks to this information, it never writes past the
973  * output buffer. However, since it doesn't know its 'src' size, it may read an
974  * unknown amount of input, past input buffer bounds. Also, since match offsets
975  * are not validated, match reads from 'src' may underflow too. These issues
976  * never happen if input (compressed) data is correct. But they may happen if
977  * input data is invalid (error or intentional tampering). As a consequence, use
978  * these functions in trusted environments with trusted data **only**.
979  */
980 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using "
982 LZ4LIB_API int LZ4_decompress_fast(const char *src, char *dst,
984 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider migrating "
985  "towards LZ4_decompress_safe_continue() instead. "
986  "Note that the contract will change (requires block's "
987  "compressed size, instead of decompressed size)")
988 LZ4LIB_API int
990  const char *src, char *dst, int originalSize);
991 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using "
993 LZ4LIB_API int LZ4_decompress_fast_usingDict(const char *src, char *dst,
995  const char *dictStart,
996  int dictSize);
997 
998 /*! LZ4_resetStream() :
999  * An LZ4_stream_t structure must be initialized at least once.
1000  * This is done with LZ4_initStream(), or LZ4_resetStream().
1001  * Consider switching to LZ4_initStream(),
1002  * invoking LZ4_resetStream() will trigger deprecation warnings in the future.
1003  */
1004 LZ4LIB_API void LZ4_resetStream(LZ4_stream_t *streamPtr);
1005 
1006 #endif /* LZ4_H_98237428734687 */
1007 
1008 #if defined(__cplusplus)
1009 }
1010 #endif
int LZ4_decompress_fast_usingDict(const char *source, char *dest, int originalSize, const char *dictStart, int dictSize)
Definition: lz4.c:3361
LZ4_FORCE_O2 int LZ4_decompress_fast_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *source, char *dest, int originalSize)
Definition: lz4.c:3263
LZ4_FORCE_O2 int LZ4_decompress_fast(const char *source, char *dest, int originalSize)
Definition: lz4.c:3028
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
LZ4LIB_API int LZ4_compress_fast_continue(LZ4_stream_t *streamPtr, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition: lz4.c:2087
#define LZ4_STREAMDECODE_MINSIZE
Definition: lz4.h:849
LZ4LIB_API int LZ4_compress(const char *src, char *dest, int srcSize)
Definition: lz4.c:3383
LZ4LIB_API char * LZ4_slideInputBuffer(void *state)
Definition: lz4.c:3449
LZ4LIB_API int LZ4_compress_fast(const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition: lz4.c:1786
LZ4LIB_API void LZ4_resetStream_fast(LZ4_stream_t *streamPtr)
Definition: lz4.c:1940
char int const char * dictStart
Definition: lz4.h:994
LZ4LIB_API int LZ4_compress_limitedOutput(const char *src, char *dest, int srcSize, int maxOutputSize)
Definition: lz4.c:3378
LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize)
Definition: lz4.c:3192
LZ4LIB_API int LZ4_decompress_safe_partial_usingDict(const char *src, char *dst, int compressedSize, int targetOutputSize, int maxOutputSize, const char *dictStart, int dictSize)
Definition: lz4.c:3337
LZ4LIB_API int LZ4_freeStreamDecode(LZ4_streamDecode_t *LZ4_stream)
Definition: lz4.c:3148
LZ4LIB_API const char * LZ4_versionString(void)
Definition: lz4.c:875
LZ4LIB_API int LZ4_decompress_safe_withPrefix64k(const char *src, char *dst, int compressedSize, int maxDstSize)
Definition: lz4.c:3039
LZ4LIB_API int LZ4_loadDictSlow(LZ4_stream_t *streamPtr, const char *dictionary, int dictSize)
Definition: lz4.c:2029
LZ4LIB_API int LZ4_saveDict(LZ4_stream_t *streamPtr, char *safeBuffer, int maxDictSize)
Definition: lz4.c:2238
LZ4LIB_API int LZ4_versionNumber(void)
Definition: lz4.c:871
LZ4LIB_API LZ4_streamDecode_t * LZ4_createStreamDecode(void)
Definition: lz4.c:3141
LZ4LIB_API void * LZ4_create(char *inputBuffer)
Definition: lz4.c:3442
LZ4LIB_API int LZ4_uncompress(const char *source, char *dest, int outputSize)
Definition: lz4.c:3417
LZ4LIB_API int LZ4_sizeofState(void)
Definition: lz4.c:883
#define LZ4_HASH_SIZE_U32
Definition: lz4.h:778
#define LZ4_STREAM_MINSIZE
Definition: lz4.h:812
LZ4LIB_API int LZ4_compressBound(int inputSize)
Definition: lz4.c:879
LZ4LIB_API int LZ4_decompress_safe(const char *src, char *dst, int compressedSize, int dstCapacity)
Definition: lz4.c:3010
LZ4LIB_API int LZ4_compress_continue(LZ4_stream_t *LZ4_streamPtr, const char *source, char *dest, int inputSize)
Definition: lz4.c:3404
LZ4LIB_API int LZ4_resetStreamState(void *state, char *inputBuffer)
Definition: lz4.c:3434
LZ4LIB_API int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, const char *dictionary, int dictSize)
Definition: lz4.c:3164
LZ4LIB_API int LZ4_decompress_safe_usingDict(const char *src, char *dst, int srcSize, int dstCapacity, const char *dictStart, int dictSize)
Definition: lz4.c:3316
LZ4LIB_API int LZ4_freeStream(LZ4_stream_t *streamPtr)
Definition: lz4.c:1946
LZ4LIB_API int LZ4_compress_limitedOutput_withState(void *state, const char *source, char *dest, int inputSize, int maxOutputSize)
Definition: lz4.c:3387
unsigned short LZ4_u16
Definition: lz4.h:791
char * dst
Definition: lz4.h:981
LZ4LIB_API LZ4_stream_t * LZ4_initStream(void *stateBuffer, size_t size)
Definition: lz4.c:1917
LZ4LIB_API int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize, int maxOutputSize)
Definition: lz4.c:3421
LZ4LIB_API int LZ4_compress_fast_extState(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition: lz4.c:1666
LZ4LIB_API int LZ4_decompress_safe_partial(const char *src, char *dst, int srcSize, int targetOutputSize, int dstCapacity)
Definition: lz4.c:3019
LZ4LIB_API int LZ4_decompress_fast_withPrefix64k(const char *src, char *dst, int originalSize)
Definition: lz4.c:3061
signed char LZ4_i8
Definition: lz4.h:789
LZ4LIB_API int LZ4_compress_limitedOutput_continue(LZ4_stream_t *LZ4_streamPtr, const char *source, char *dest, int inputSize, int maxOutputSize)
Definition: lz4.c:3397
LZ4LIB_API int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary, int dictSize)
Definition: lz4.c:2024
LZ4LIB_API void LZ4_attach_dictionary(LZ4_stream_t *workingStream, const LZ4_stream_t *dictionaryStream)
Definition: lz4.c:2035
LZ4LIB_API int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *src, char *dst, int srcSize, int dstCapacity)
Definition: lz4.c:3212
LZ4LIB_API void LZ4_resetStream(LZ4_stream_t *streamPtr)
Definition: lz4.c:1934
unsigned char LZ4_byte
Definition: lz4.h:790
char int originalSize
Definition: lz4.h:982
char int const char int dictSize
Definition: lz4.h:995
LZ4LIB_API int LZ4_compress_destSize(const char *src, char *dst, int *srcSizePtr, int targetDstSize)
Definition: lz4.c:1865
LZ4LIB_API int LZ4_compress_default(const char *src, char *dst, int srcSize, int dstCapacity)
Definition: lz4.c:1808
LZ4LIB_API LZ4_stream_t * LZ4_createStream(void)
Definition: lz4.c:1892
LZ4LIB_API int LZ4_sizeofStreamState(void)
Definition: lz4.c:3429
LZ4LIB_API int LZ4_compress_withState(void *state, const char *source, char *dest, int inputSize)
Definition: lz4.c:3392
const char * src
Definition: lz4.h:989
unsigned int LZ4_u32
Definition: lz4.h:792
#define LZ4_DEPRECATED(message)
Definition: lz4.h:885
struct state state
Definition: parser.c:103
const LZ4_stream_t_internal * dictCtx
Definition: lz4.h:805
LZ4_u32 tableType
Definition: lz4.h:807
LZ4_u32 currentOffset
Definition: lz4.h:806
const LZ4_byte * dictionary
Definition: lz4.h:804
LZ4_u32 dictSize
Definition: lz4.h:808
LZ4_u32 hashTable[LZ4_HASH_SIZE_U32]
Definition: lz4.h:803
LZ4_streamDecode_t_internal internal_donotuse
Definition: lz4.h:852
char minStateSize[LZ4_STREAMDECODE_MINSIZE]
Definition: lz4.h:851
char minStateSize[LZ4_STREAM_MINSIZE]
Definition: lz4.h:816
LZ4_stream_t_internal internal_donotuse
Definition: lz4.h:817