summaryrefslogtreecommitdiffstats
path: root/lib/lz4.c
Commit message (Collapse)AuthorAgeFilesLines
* fix rare ubYann Collet2022-09-171-6/+8
| | | | | apparently, accessing the short member of a union still requires enough space for its largest member.
* removed a few more usages of base ptrYann Collet2022-09-161-15/+20
| | | | | | | by making LZ4_putPosition() specific to byPtr strategy. byU32 and byU16 use LZ4_putIndexOnHash() instead. In both cases, it makes it irrelevant to pass` base as reference ptr.
* remove another usage of baseYann Collet2022-09-161-4/+6
| | | | | within `LZ4_loadDict()` function : it's possible to only employ Indexes directly.
* fix benchmark more using DictionaryYann Collet2022-09-151-6/+23
| | | | | | | 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
* simplify getPositionYann Collet2022-09-121-9/+7
| | | | | it's only used in byPtr mode. This removes the need to transfer `base` ptr value.
* Suppress false positive warning from MSVCTakayuki Matsuoka2022-08-121-0/+7
| | | | | | | | | | | | MSVC (17.3 or earlier) reports the following warning lz4\lib\lz4.c(527): warning C6385: Reading invalid data from 'v'. Line 527 is : LZ4_memcpy(&v[4], v, 4); But, obviously v[0..3] is always filled with meaningful value. Therefore, this warning report is wrong. We must revisit this issue with future version of MSVC.
* Fix document for LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION in lz4.cTakayuki Matsuoka2022-08-111-1/+6
|
* Merge pull request #1129 from t-mat/disable-memory-alloc-add-docYann Collet2022-08-101-0/+11
|\ | | | | Add document for LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION
| * Add: Doxygen comment for LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATIONTakayuki Matsuoka2022-08-061-0/+11
| |
* | Add LZ4_FREESTANDINGTakayuki Matsuoka2022-08-071-1/+3
|/
* Merge pull request #1124 from t-mat/compile-time-purge-memalloc-funcYann Collet2022-08-051-1/+13
|\ | | | | Introduce LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION
| * Fix : Internal memory allocation macro namesTakayuki Matsuoka2022-07-311-6/+3
| |
| * Introduce LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATIONTakayuki Matsuoka2022-07-311-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | simplify read_variable_length()Yann Collet2022-08-031-26/+24
| | | | | | | | single sumtype return value
* | refactor read_variable_length()Yann Collet2022-08-021-19/+29
| | | | | | | | | | updated documentation, more assert(), overflow detection in 32-bit mode
* | remove support of decompress_fast*() from decompress_generic()Yann Collet2022-08-021-92/+43
| | | | | | | | | | | | | | since it's now supported by decompress_unsafe(). The goal is to improve maintenability of decompress_generic() by reducing its complexity.
* | introduce LZ4_decompress_unsafe_generic()Yann Collet2022-08-021-18/+158
| | | | | | | | | | | | | | designed to support specifically LZ4_decompress_fast*() variants. The end goal is to offload this support from LZ4_decompress_generic to improve its maintenance.
* | fix: various typosDominique Pelle2022-07-311-1/+1
| |
* | New macro for memcpy, memmove and memsetTakayuki Matsuoka2022-07-311-9/+22
|/ | | | | | | | 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.
* clarify static sizes of states for static allocationYann Collet2022-07-121-6/+5
|
* silence a useless MSVC warningYann Collet2022-07-041-0/+1
|
* API: add `LZ4_decompress_safe_partial_usingDict` APIQi Wang2022-06-071-1/+48
| | | | | | feature request: #1051 Signed-off-by: Qi Wang <wangqi@linux.alibaba.com>
* Introduce MIN and MAX bounds to LZ4_MEMORY_USAGEYann Collet2022-01-311-1/+1
| | | | | | | ensure that `frametest` works fine with these values, notably with low LZ4_MEMORY_USAGE (dict test notably) following suggestions from @t-mat at #1016
* renamed unaligned -> LZ4_unalignedYann Collet2022-01-291-6/+6
| | | | | better name space isolation suggested by @boris-kolpackov in #1053
* Add commentsBen Niu2022-01-271-0/+5
|
* Disable _tzcnt_u64 for ARM64ECBen Niu2022-01-271-1/+1
| | | The ARM64EC is a new Microsoft-designed ARM64 ABI that is compatible with AMD64 code. However, not all AMD64 intrinsic functions are supported. For, intrinsics that are lowered to AVX, AVX2 and AVX512 instructions are not supported, including the _tzcnt_u64. To make sure this file compiles for ARM64EC, the use of _tzcnt_u64 should be neutered.
* Enable fast decoding on Apple/AArch64 buildsArseny Kapoulkine2021-11-221-3/+5
| | | | | | | | | | | This makes decoding significantly faster on M1; measured on compressed source code across 8 hardware threads, decompressing 294 MB to 1301 MB takes 513 ms of cumulative work (2.53 GB/s) before, and 406 ms (3.2 GB/s) after this change on M1 Pro. There's no way to check if the target architecture is M1 specifically but the gains are likely to be similar on recent iterations on Apple processors, and the original performance issue was probably more specific to Qualcomm.
* fix clang-cl _tzcnt_u64 not defined issueZeyi (Rice) Fan2021-08-091-0/+6
|
* Cast ALLOC return value to satisfy C++Gabe Jones2021-06-151-1/+1
|
* fix NULL ptr arithmetic at lz4:2299Yann Collet2021-05-281-2/+7
|
* fix NULL ptr arithmetic in lz4:1680Yann Collet2021-05-281-3/+6
| | | | only do arithmetic if offset > 0
* fix UB lz4:988 and lz4:1178Yann Collet2021-05-281-28/+38
| | | | | ensure `dictBase` is only used when there is an actual dictionary content.
* fix NULL ptr arithmetic of lz4:1572Yann Collet2021-05-281-5/+5
| | | | was blindly adding an offset (0) to `dictionary` which could be `NULL`.
* Fix potential memory corruption with negative memmove() sizeJasper Lievisse Adriaanse2021-02-261-1/+1
|
* fix some typos (work by Andrea Gelmini)Thomas Waldmann2021-01-071-1/+1
|
* fix minor header dateYann Collet2020-12-011-1/+1
|
* better visual conformanceYann Collet2020-11-151-4/+3
| | | | | | only include <intrin.h> on vs2005+ (#947) remove some useless #pragma fix a few minor Visual warnings
* restrict BitScanForward() to VS2005+Yann Collet2020-11-141-1/+1
| | | | suggested by @aqrit in #947
* changed LZ4_calloc() to a 2-arguments signatureYann Collet2020-11-091-2/+2
| | | | | | to remain similar to stdlib's calloc(). Updated test to use c++ compiler for stricter signature check.
* Merge branch 'dev' into customMemYann Collet2020-11-091-2/+2
|\
| * Merge pull request #944 from lz4/fix874Yann Collet2020-11-091-1/+1
| |\ | | | | | | fix #874
| | * fix #874Yann Collet2020-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | coverity reported a warning regarding a memcpy() overwrite. This is a false positive (the memory area is large enough), but it's true that it's not trivial to determine (encompassing struct), and it's proper anyway to only memcpy() just the right amount of data.
| * | fixed remaining ubsan warningsYann Collet2020-11-091-1/+1
| |/
* | first proposal for LZ4_USER_MEMORY_FUNCTIONSYann Collet2020-11-091-4/+17
|/ | | | | | | | | 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-1/+3
| | | | | - check alignment before casting a pointer - saveDict : don't memmove() on NULL dst
* Merge pull request #941 from lz4/revertinlineYann Collet2020-11-081-18/+18
|\ | | | | Revert "Replace "static" to "LZ4_FORCE_INLINE" for small functions"
| * Revert "Replace "static" to "LZ4_FORCE_INLINE" for small functions"Yann Collet2020-11-071-18/+18
| | | | | | | | This reverts commit 0e3933edd435c54cc2e21e38f5d4ba7bf644a24e.
* | fix #935Yann Collet2020-11-071-2/+3
|/ | | | | | | 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-12/+19
|\ | | | | More alignment tests
| * re-enable alignment test on all targetsYann Collet2020-11-071-14/+6
| |