1
0
mirror of https://github.com/lz4/lz4.git synced 2026-10-24 01:48:57 +03:00

125 Commits

Author SHA1 Message Date
Yann Collet
d9c9fe23a2 lz4frame: explicit reserved fields ; LZ4F_srcStableUntilFlush includes LZ4F_srcStable (checkpoint)
Prototype, not intended for a PR as is.

- LZ4F_preferences_t : reserved array replaced by explicit scalar fields
  (nbWorkers, reserved1, reserved0), and LZ4F_compressOptions_t likewise
  (stableSrc, reserved2, reserved1, reserved0), as LZ4F_decompressOptions_t.
  Same sizes and offsets (ABI unchanged). A future field takes the place of a
  reserved one, without changing positional initializers.
  One-time source change : the former positional form { ..., { 0, 0, 0 } }
  no longer compiles in C++ (warnings in C) ; examples/frameCompress.c updated.
  LZ4F_INIT_PREFERENCES : { LZ4F_INIT_FRAMEINFO, 0, 0u, 0u, 0u, 0u, 0u }.
- LZ4F_srcStableUntilFlush (2) is stronger than LZ4F_srcStable (1) : in addition
  to the last 64 KB of input (which remain, including after LZ4F_flush()),
  all of src remains until LZ4F_flush() / LZ4F_compressEnd() returns
  (with autoFlush : until the invocation returns). Docs only : the code already
  relied on this (history read in place after a flush, single-threaded path).
- tests/frameMT.c : validateFlushContract : one buffer, 2 invocations separated by
  a flush, everything but the last 64 KB scrambled after the flush with content
  resembling upcoming data ; nbWorkers 0 and 2, levels 1 and 9, with and without
  autoFlush. Scrambling the last 64 KB too is detected (contentChecksum_invalid).
  Streaming test : LZ4F_srcStableUntilFlush slices come from a working copy,
  scrambled the same way after each flush.

Output unchanged (same digests). Validated : full tests MT / no-MT, ASAN+UBSAN, TSAN,
make test, wine, examples (C, C++), cxxtest, CLI == dev CLI.
2026-10-22 04:26:50 -07:00
Yann Collet
4b523c7ed6 Merge pull request #1642 from Benjamin-Philip/bp/docs-clean-up-stream-example
Touch up line by line compression example
2026-10-19 08:01:25 -07:00
Yann Collet
8c920a0bf1 lineByLine example: LZ4 forgets old lines, it doesn't clear them
The data stays in the ring buffer; only the dictionary is reduced to
Line#X+1. Also fix a missing space.
2026-10-18 12:33:12 -07:00
Yann Collet
dba32ed029 examples: fileCompress reports the error from LZ4F_writeClose()
It displayed the result of the previous operation instead.
2026-10-14 21:20:58 -07:00
Yann Collet
fc588ab172 examples: fileRandomAccess, using LZ4F_seek() and LZ4F_tell() 2026-10-13 22:42:30 -07:00
Alb3e3
72852fcea2 examples: cast division denominators to double
The macOS CI job builds the examples with

    CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" make test

and clang's -Wconversion implies -Wimplicit-int-float-conversion.  In each of
these ratio expressions the numerator is cast explicitly but the denominator is
left to convert implicitly, so newer clang rejects them:

    frameCompress.c:446:40: error: implicit conversion from
        'const unsigned long long' to 'double' may lose precision
        [-Werror,-Wimplicit-int-float-conversion]
      446 |             (double)ret.size_out / ret.size_in * 100);
          |                                  ~ ~~~~^~~~~~~

Cast the denominators too, matching how fileCompress.c:193 already writes the
same computation.  The conversion happened anyway via the usual arithmetic
conversions, so the printed values are unchanged.

frameCompress.c is only the first failure; make stops there, and
bench_functions.c has ten more instances of the same pattern behind it.
2026-10-07 14:47:53 -07:00
Yann Collet
6f8f65d2c4 fix minor yet complex issue involving thread pool
in the context of multiple Makefile invoking each other.
2026-01-25 12:02:46 -08:00
Benjamin Philip
da2481db3d Expand "What's the point of this example?" 2025-08-16 20:07:04 +05:30
Benjamin Philip
e86c1217b6 Expand "What's the point of this example?" 2025-08-16 19:59:30 +05:30
Benjamin Philip
64ddd69095 Format 2025-08-16 19:49:06 +05:30
Benjamin Philip
bf41eb8700 Fix grammar 2025-08-16 19:42:12 +05:30
Benjamin Philip
3ecbee3dc9 Split ASCII illustrations 2025-08-16 19:05:36 +05:30
Benjamin Philip
d4534bd9a2 Fix grammar 2025-08-16 18:04:25 +05:30
Benjamin Philip
7eb043dc85 Format
This commit formats each paragraph, and wraps references to variables in
the illustration with inline code.
2025-08-16 16:45:59 +05:30
Benjamin Philip
5ddfa6a6f9 Split ASCII illustrations
This commit splits the ASCII illustrations and places them in a more
natural to read order.
2025-08-16 16:34:14 +05:30
Yann Collet
672d141b99 minor refactor of LZ4F_read() in lz4file.c 2025-05-23 19:22:05 -07:00
Yann Collet
56d804309c examples create their own version of liblz4.a
to avoid race conditions during parallel builds and tests
2025-05-05 20:05:45 -07:00
louislafosse
20bdcaae09 fix(segv): add null pointer assertions for file pointers in example files 2025-03-25 01:28:48 +01:00
Yann Collet
923839bbc9 fixed minor static analyzer warning in fileCompress example 2025-01-12 23:30:55 -08:00
t-mat
855a097886 chore: Fix dictionaryRandomAccess's issue for small file
When size of the given file is less than 1024 (DICTIONARY_BYTES), dict[] may contain garbage.
Therefore, test_decompress() fails with garbage dictionary.

This change set fixes the failure of test for dictionaryRandomAccess with TESTFILE_SMALL.
2024-11-18 16:43:13 +09:00
t-mat
184ffbd686 chore: Add test for dictionaryRandomAccess
dictionaryRandomAccess doesn't pass this test.
This issue will be fixed in the follow up change set.

Actual failure log:
./dictionaryRandomAccess .gitignore .gitignore 0 32
inp    = [.gitignore]
lz4    = [.gitignore.lz4s-1024]
dec    = [.gitignore.lz4s-1024.dec]
dict   = [.gitignore]
offset = [0]
length = [32]
compress : .gitignore -> .gitignore.lz4s-1024
compress : done
decompress : .gitignore.lz4s-1024 -> .gitignore.lz4s-1024.dec
decompress : done
verify : .gitignore <-> .gitignore.lz4s-1024.dec
verify : NG
2024-11-18 16:42:50 +09:00
Yann Collet
aafb56ee2e update gpl license to 2.0-or-later
The text at the top of each source file was already specifying 2.0-or-later,
but this wasn't clearly reflected in the full-text license in COPYING,
which was the old 2.0 license, which can be interpreted as 2.0-only.

Note that the license of `liblz4`, the library in `lib/` directory,
is unchanged, and remains the more permissive `BSD 2-clause`.
2024-07-10 07:26:20 +02:00
Yann Collet
e2e8d9b06b rename USERCFLAGS for consistency 2023-12-24 16:07:10 -08:00
Yann Collet
631cd0f6fd minor adjustments for examples/Makefile 2023-12-23 13:22:41 -08:00
Yann Collet
6bdfc56c9a fix minor conversion warnings on macos 2023-12-22 20:11:12 -08:00
Yann Collet
8586d6a1b2 fix example for low resolution timers 2023-09-26 12:56:56 -07:00
Yann Collet
65d3772592 fix minor c++ compat warning 2023-09-26 12:56:56 -07:00
Yann Collet
67532ae3c5 fix examples
streamlined Makefile.
avoid usage of -lrt (problematic for portability).
now bench_functions (renamed) can be part of `make test`.

fix #1276
2023-09-26 12:56:56 -07:00
Takayuki Matsuoka
ccef95b821 fix: issue #1248
Fix issue #1248, reported by @BojackMa.
2023-07-11 18:17:11 +09:00
Dimitri Papadopoulos
13c508ea15 Discard trailing spaces 2023-06-25 17:43:56 +02:00
Dominique Pelle
3347485307 fix: various typos 2022-07-31 17:47:00 +02:00
Yann Collet
4da5c4dd30 Merge pull request #1094 from alexmohr/add-uncompressed-api
frame-api: add function to insert uncomressed data
2022-07-05 15:07:36 -07:00
Alexander Mohr
5c7382798e review: Fix review findings
This commit fixes the review findings

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
2022-06-10 06:37:57 +00:00
Alexander Mohr
4aeb5020c3 frame-api: add method to insert uncomressed data
new method `uncompressed_update` allows to insert blocks without
compression into the lz4 stream.
The usage is documented in the frameCompress example

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
2022-06-09 17:08:01 +02:00
Qi Wang
51be2943b3 docs: fix some typo
Signed-off-by: Qi Wang <wangqi@linux.alibaba.com>
2022-06-06 10:29:37 +08:00
anjiahao
f5625f260e add file operation and examples
operate lz4 compressed files as a general files

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-03-10 13:28:34 +08:00
Dimitri Papadopoulos
4bdfb08b95 Fix typos found by codespell 2021-11-25 15:32:37 +01:00
Takayuki Matsuoka
2fbf12add7 Add C++ compatibility test for examples/ 2021-09-07 01:03:04 +09:00
Takayuki Matsuoka
1b0a501a19 Add cast operator for compatibility with C++ 2021-09-07 01:02:23 +09:00
kmou424
a3960899f4 examples: simple_buffer: We must explicit convert pointer after malloc in c++
Aim: To adapt C++

Compilation errors:
simple_buffer.c:47:9: error: cannot initialize a variable of type 'char *' with an rvalue of type 'void *'
  char* compressed_data = malloc((size_t)max_dst_size);
        ^                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
simple_buffer.c:76:15: error: cannot initialize a variable of type 'char *const' with an rvalue of type 'void *'
  char* const regen_buffer = malloc(src_size);
              ^              ~~~~~~~~~~~~~~~~
2 errors generated.
2021-09-05 02:52:57 +08:00
a1346054
eb23590d13 fix spelling 2021-08-21 20:50:38 +00:00
Takayuki Matsuoka
28cb94f53a Fix -Wshorten-64-to-32 warning
Fix -Wshorten-64-to-32 warning

The following CI test (macOS) reports "-Wshorten-64-to-32" warning

make V=1 clean test MOREFLAGS='-Werror -Wconversion -Wno-sign-conversion'

```
blockStreaming_lineByLine.c:68:54: error: implicit conversion loses integer precision: 'const size_t' (aka 'const unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
                lz4Stream, inpPtr, cmpBuf, inpBytes, cmpBufBytes, 1);
                                                     ^~~~~~~~~~~
```
2021-05-30 16:49:24 +09:00
Takayuki Matsuoka
4a9bbc2480 Fix -Wshorten-64-to-32 warning 2021-05-27 21:12:39 +09:00
Yann Collet
87a80acbe7 updated license & header dates 2020-11-25 14:45:14 -08:00
Yann Collet
0760724577 update doc 2020-11-15 01:31:09 -08:00
Andrew Martin
059682fb01 Fix typos in streaming_api_basics.md 2019-11-30 06:58:54 -05:00
Yann Collet
28964f4bea fixed #778
fixed assert() when divisor == 0
2019-08-21 13:44:24 +02:00
Yann Collet
f1e8e806e0 keep the "lorem ipsum" topic of the example string
but make it compressible
2019-07-11 17:29:16 -07:00
Hamid Zare
771a7192d6 print the compression ratio 2019-07-11 14:39:29 -07:00
Hamid Zare
658ab8fca1 changed the input text to something more compression friendly 2019-07-11 14:35:51 -07:00