Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files for lz4 1.9.4 #4726

Merged
merged 6 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add instructions and update memory alloc/free
  • Loading branch information
milindl committed Jun 6, 2024
commit 007c19d023578caa22dd5e10f3279c155082cc7b
28 changes: 28 additions & 0 deletions src/README.lz4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Instructions for Updating LZ4 Version

This document describes the steps to update the bundled lz4 version, that is,
the version used when `./configure` is run with `--disable-lz4-ext`.

1. For each file in the [lz4 repository's](https://github.com/lz4/lz4/) `lib`
directory (checked out to the appropriate version tag), copy it into the
librdkafka `src` directory, overwriting the previous files.
2. Copy `xxhash.h` and `xxhash.c` files, and rename them to `rdxxhash.h` and
`rdxxhash.c`, respectively, replacing the previous files.
3. Replace the `#else` block of the
`#if defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)`
with the following code, including the comment:
```c
#else
/* NOTE: While upgrading the lz4 version, replace the original `#else` block
* in the code with this block, and retain this comment. */
struct rdkafka_s;
extern void *rd_kafka_mem_malloc(struct rdkafka_s *rk, size_t s);
extern void *rd_kafka_mem_calloc(struct rdkafka_s *rk, size_t n, size_t s);
extern void rd_kafka_mem_free(struct rdkafka_s *rk, void *p);
# define ALLOC(s) rd_kafka_mem_malloc(NULL, s)
# define ALLOC_AND_ZERO(s) rd_kafka_mem_calloc(NULL, 1, s)
# define FREEMEM(p) rd_kafka_mem_free(NULL, p)
#endif
```
4. Run `./configure` with `--disable-lz4-ext` option, make and run test 0017.
5. Update CHANGELOG.md.
13 changes: 9 additions & 4 deletions src/lz4.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,15 @@ void LZ4_free(void* p);
# define ALLOC_AND_ZERO(s) LZ4_calloc(1,s)
# define FREEMEM(p) LZ4_free(p)
#else
# include <stdlib.h> /* malloc, calloc, free */
# define ALLOC(s) malloc(s)
# define ALLOC_AND_ZERO(s) calloc(1,s)
# define FREEMEM(p) free(p)
/* NOTE: While upgrading the lz4 version, replace the original `#else` block
* in the code with this block, and retain this comment. */
struct rdkafka_s;
extern void *rd_kafka_mem_malloc(struct rdkafka_s *rk, size_t s);
extern void *rd_kafka_mem_calloc(struct rdkafka_s *rk, size_t n, size_t s);
extern void rd_kafka_mem_free(struct rdkafka_s *rk, void *p);
# define ALLOC(s) rd_kafka_mem_malloc(NULL, s)
# define ALLOC_AND_ZERO(s) rd_kafka_mem_calloc(NULL, 1, s)
# define FREEMEM(p) rd_kafka_mem_free(NULL, p)
#endif

#if ! LZ4_FREESTANDING
Expand Down