Skip to content

Commit

Permalink
Rename z{malloc,calloc,realloc,free} into valkey_{malloc,calloc,reall…
Browse files Browse the repository at this point in the history
…oc,free} (valkey-io#1169)

The zcalloc symbol is a symbol name already used by zlib, which is
defining other names using the "z" prefix specific to zlib. In practice,
linking valkey with a static openssl, which itself might depend on a
static libz will result in link time error rejecting multiple symbol
definitions.

Fixes: valkey-io#1157

Signed-off-by: Romain Geissler <romain.geissler@amadeus.com>
  • Loading branch information
Romain-Geissler-1A authored and eifrah-aws committed Oct 20, 2024
1 parent 3967aff commit a05fc0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 6 additions & 6 deletions deps/hdr_histogram/hdr_redis_malloc.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef HDR_MALLOC_H__
#define HDR_MALLOC_H__

void *zmalloc(size_t size);
void *valkey_malloc(size_t size);
void *zcalloc_num(size_t num, size_t size);
void *zrealloc(void *ptr, size_t size);
void zfree(void *ptr);
void *valkey_realloc(void *ptr, size_t size);
void valkey_free(void *ptr);

#define hdr_malloc zmalloc
#define hdr_malloc valkey_malloc
#define hdr_calloc zcalloc_num
#define hdr_realloc zrealloc
#define hdr_free zfree
#define hdr_realloc valkey_realloc
#define hdr_free valkey_free
#endif
9 changes: 9 additions & 0 deletions src/zmalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@
#define HAVE_DEFRAG
#endif

/* The zcalloc symbol is a symbol name already used by zlib, which is defining
* other names using the "z" prefix specific to zlib. In practice, linking
* valkey with a static openssl, which itself might depend on a static libz
* will result in link time error rejecting multiple symbol definitions. */
#define zmalloc valkey_malloc
#define zcalloc valkey_calloc
#define zrealloc valkey_realloc
#define zfree valkey_free

/* 'noinline' attribute is intended to prevent the `-Wstringop-overread` warning
* when using gcc-12 later with LTO enabled. It may be removed once the
* bug[https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96503] is fixed. */
Expand Down

0 comments on commit a05fc0e

Please sign in to comment.