summaryrefslogtreecommitdiffstats
path: root/lib/lz4hc.c
Commit message (Collapse)AuthorAgeFilesLines
* fixed minor UB warningYann Collet2022-09-161-12/+13
| | | | now, even intermediate ptr arithmetic results can be UB ??
* fix benchmark more using DictionaryYann Collet2022-09-151-3/+10
| | | | | | | benchmark dictionary mode, implemented in #808, is incorrect. It would desynchronize compression and decompression as soon as 2+ files are dictionary compressed. Also : slightly improved traces system, to also include __LINE__ number
* fixed a few ubsan warnings in lz4hcYann Collet2022-09-091-18/+18
| | | | mostly related to pointer arithmetic involving NULL ptr.
* Fix: Disable LZ4HC correspond functions when ↵Takayuki Matsuoka2022-08-071-0/+2
| | | | LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION is enabled
* Merge pull request #1124 from t-mat/compile-time-purge-memalloc-funcYann Collet2022-08-051-0/+2
|\ | | | | Introduce LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION
| * Introduce LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATIONTakayuki Matsuoka2022-07-311-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset introduces new compile time switch macro LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION which removes the following functions when it's defined. ``` // lz4.c LZ4_createStream LZ4_freeStream LZ4_createStreamDecode LZ4_freeStreamDecode LZ4_create // legacy // lz4hc.c LZ4_createStreamHC(void) LZ4_freeStreamHC LZ4_createHC // legacy LZ4_freeHC // legacy ``` These functions uses dynamic memory allocation functions such as malloc() and free(). It'll be useful for freestanding environment which doesn't have these allocation functions. Since this change breaks API, this macro is only valid with lz4 as a static linked object.
* | New macro for memcpy, memmove and memsetTakayuki Matsuoka2022-07-311-4/+4
|/ | | | | | | | This changeset introduces the following external macros. - Add new macro LZ4_memset() which enables to inject external function as memset(). - Similar macro LZ4_memmove() for memmove(). - In same manner, LZ4_memcpy() also can be overriden by external macro.
* removed ->dictBase from lz4hc stateYann Collet2022-07-131-26/+33
| | | | replaced by ->dictStart
* removed ->base from lz4hc stateYann Collet2022-07-131-66/+67
| | | | replaced by ->prefixStart
* clarify static sizes of states for static allocationYann Collet2022-07-121-3/+1
|
* added target test-compile-with-lz4-memory-usageYann Collet2022-01-311-0/+2
| | | | and run it in GA CI
* fixed bug in optimal parserYann Collet2022-01-291-19/+17
| | | | discovered by @yoniko.
* Fix typos found by codespellDimitri Papadopoulos2021-11-251-2/+2
|
* fix LZ4HC_HEAPMODE macro guardTotalJustice2021-06-251-3/+3
|
* fix null pointer dereferenceklebertosantos2021-03-101-1/+3
|
* Don't trigger UBSan warning in LZ4_resetStreamHC_fast if ↵Simon Giesecke2021-01-071-1/+5
| | | | LZ4_streamHCPtr->internal_donotuse.end is NULL.
* updated license & header datesYann Collet2020-11-251-1/+1
|
* fix minor win32 warningYann Collet2020-11-151-1/+2
|
* Merge branch 'dev' into customMemYann Collet2020-11-091-2/+5
|\
| * fixed remaining ubsan warningsYann Collet2020-11-091-2/+5
| |
* | first proposal for LZ4_USER_MEMORY_FUNCTIONSYann Collet2020-11-091-8/+7
|/ | | | | | | | | makes it possible to replace at link time malloc, calloc and free by user-provided functions which must be named LZ4_malloc(), LZ4_calloc() and LZ4_free(). answer #937
* fix minor UBsYann Collet2020-11-081-2/+2
| | | | | - check alignment before casting a pointer - saveDict : don't memmove() on NULL dst
* fix #926Yann Collet2020-11-081-18/+20
| | | | | fix incorrect behavior of LZ4_saveDictHC() when invoked right after initialization.
* Merge pull request #941 from lz4/revertinlineYann Collet2020-11-081-2/+2
|\ | | | | Revert "Replace "static" to "LZ4_FORCE_INLINE" for small functions"
| * Revert "Replace "static" to "LZ4_FORCE_INLINE" for small functions"Yann Collet2020-11-071-2/+2
| | | | | | | | This reverts commit 0e3933edd435c54cc2e21e38f5d4ba7bf644a24e.
* | fix #935Yann Collet2020-11-071-1/+1
|/ | | | | | | minor: identical declaration and prototypes of `LZ4HC_compress_optimal()` also : very minor optimization of `LZ4_memcpy_using_offset()`
* Merge pull request #936 from lz4/alignTestYann Collet2020-11-071-22/+13
|\ | | | | More alignment tests
| * unified alignment testYann Collet2020-11-061-18/+6
| | | | | | | | across lz4.c and lz4hc.c
| * preserver alignment test on Visual Studio x64Yann Collet2020-10-021-16/+19
| | | | | | | | | | this it works fine in this environment (only x86 is suspicious)
* | Merge pull request #930 from remittor-pr/fix_msvcYann Collet2020-10-311-2/+2
|\ \ | | | | | | Fix: The "inline" specifier do not use for LZ4_wildCopy8 and LZ4_wildCopy32
| * | Replace "static" to "LZ4_FORCE_INLINE" for small functionsremittor2020-10-071-2/+2
| |/ | | | | | | The "static" specifier does not guarantee that the function will be inlined.
* | [lz4hc] Made function LZ4HC_encodeSequence a human readableremittor2020-10-031-23/+30
|/
* fix bad init scenarioYann Collet2020-10-011-3/+5
|
* fix minor static analyzer warningsYann Collet2020-09-301-10/+9
| | | | | detected by scan-build, cppcheck and advanved compilation flags fix #786
* ensure last match not too close to endYann Collet2020-09-281-15/+29
| | | | must respect MFLIMIT distance from oend
* fix incorrect countingYann Collet2020-09-281-2/+3
| | | | after truncation of last sequence
* fix efficiency of LZ4_compress_HC_destSize()Yann Collet2020-09-281-24/+66
| | | | | | | | | | | | | LZ4_compress_HC_destSize() had a tendency to discard its last match when this match overflowed specified dstBuffer limit. The impact is generally moderate, but occasionally huge, typically when this last match is very large (such as compressing a bunch of zeroes). Issue #784 fixed for both Chain and Opt implementations. Added a unit test suggested by @remittor checking this topic.
* Reducing stack usage in _t_alignment checksAleksandr Kukuev2020-05-111-2/+2
|
* fix malloc handlingYan Pashkovsky2020-02-031-1/+4
|
* fix: allocate LZ4HC_optimal_t opt on heap each time (#837)Yan Pashkovsky2020-01-311-3/+16
|
* fixed lz4hc assert errorYann Collet2019-12-031-3/+3
| | | | | | | | | | | | | when src ptr is in very low memory area (< 64K), the virtual reference to data in dictionary might end up in a very high memory address. Since it's not a "real" memory address, just a virtual one, to calculate distance, it doesn't matter : only distance matters. The assert was to restrictive. Fixed.
* [lz4hc] Chain swap with accelerationNick Terrell2019-07-311-4/+10
|
* [lz4hc] Only allow chain swapping forwardsNick Terrell2019-07-311-1/+1
| | | | | | When the match is very long and found quickly, we can do matchLength * nbCompares iterations through the chain swapping, which can really slow down compression.
* [lz4hc] Fix pattern detection end of dictionaryNick Terrell2019-07-311-20/+45
| | | | | | The pattern detection in extDict mode could put `matchIndex` within the last 3 bytes of the dictionary. This would cause a read out of bounds.
* [lz4hc] Fix minor pessimization in extDict pattern matchingNick Terrell2019-07-311-1/+1
| | | | | | We should be comparing `matchPtr` not `ip`. This bug just means that this branch was not taken, so we might miss some of the forward length.
* [lz4hc] Improve pattern detection in ext dictNick Terrell2019-07-311-5/+13
| | | | | | | | | | | | It is important to continue to look backwards if the current pattern reaches `lowPrefixPtr`. If the pattern detection doesn't go all the way to the beginning of the pattern, or the end of the pattern it slows down the search instead of speeding it up. The slow unit in `round_trip_stream_fuzzer` used to take 12 seconds to run with -O3, now it takes 0.2 seconds. Credit to OSS-Fuzz
* [LZ4HC] Speed up pattern compression with external dictionaryNick Terrell2019-07-241-27/+47
| | | | Fixes #761.
* Unconditionally Clear `dictCtx`W. Felix Handte2019-07-181-5/+3
|
* Fix Data Corruption Bug when Streaming with an Attached Dict in HC ModeW. Felix Handte2019-07-181-0/+5
| | | | | | | | | | | | This diff fixes an issue in which we failed to clear the `dictCtx` in HC compression. The `dictCtx` is not supposed to be used when an `extDict` is present: matches found in the `dictCtx` do not account for the presence of an `extDict` segment, and their offsets are therefore miscalculated when one is present. This can lead to data corruption. This diff clears the `dictCtx` whenever setting an `extDict`. This issue was uncovered by @terrelln's fuzzing work.
* bugfix: correctly control the offset < LZ4_DISTANCE_MAX,when change the ↵Hitatm2019-07-151-1/+1
| | | | value of LZ4_DISTANCE_MAX,