Fix prefixing for internal functions calloc/cfree

This commit is contained in:
Hans Kristian Rosbach 2023-02-07 10:05:19 +01:00 committed by Hans Kristian Rosbach
parent 6c09fa2613
commit cf5bb01da9
7 changed files with 16 additions and 22 deletions

View File

@ -202,11 +202,11 @@ int32_t ZNG_CONDEXPORT PREFIX(deflateInit2)(PREFIX3(stream) *strm, int32_t level
strm->msg = NULL; strm->msg = NULL;
if (strm->zalloc == NULL) { if (strm->zalloc == NULL) {
strm->zalloc = PREFIX3(calloc); strm->zalloc = PREFIX(zcalloc);
strm->opaque = NULL; strm->opaque = NULL;
} }
if (strm->zfree == NULL) if (strm->zfree == NULL)
strm->zfree = PREFIX3(cfree); strm->zfree = PREFIX(zcfree);
if (level == Z_DEFAULT_COMPRESSION) if (level == Z_DEFAULT_COMPRESSION)
level = 6; level = 6;

View File

@ -38,11 +38,11 @@ int32_t ZNG_CONDEXPORT PREFIX(inflateBackInit)(PREFIX3(stream) *strm, int32_t wi
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
strm->msg = NULL; /* in case we return an error */ strm->msg = NULL; /* in case we return an error */
if (strm->zalloc == NULL) { if (strm->zalloc == NULL) {
strm->zalloc = PREFIX3(calloc); strm->zalloc = PREFIX(zcalloc);
strm->opaque = NULL; strm->opaque = NULL;
} }
if (strm->zfree == NULL) if (strm->zfree == NULL)
strm->zfree = PREFIX3(cfree); strm->zfree = PREFIX(zcfree);
state = ZALLOC_INFLATE_STATE(strm); state = ZALLOC_INFLATE_STATE(strm);
if (state == NULL) if (state == NULL)
return Z_MEM_ERROR; return Z_MEM_ERROR;

View File

@ -146,11 +146,11 @@ int32_t ZNG_CONDEXPORT PREFIX(inflateInit2)(PREFIX3(stream) *strm, int32_t windo
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
strm->msg = NULL; /* in case we return an error */ strm->msg = NULL; /* in case we return an error */
if (strm->zalloc == NULL) { if (strm->zalloc == NULL) {
strm->zalloc = PREFIX3(calloc); strm->zalloc = PREFIX(zcalloc);
strm->opaque = NULL; strm->opaque = NULL;
} }
if (strm->zfree == NULL) if (strm->zfree == NULL)
strm->zfree = PREFIX3(cfree); strm->zfree = PREFIX(zcfree);
state = ZALLOC_INFLATE_STATE(strm); state = ZALLOC_INFLATE_STATE(strm);
if (state == NULL) if (state == NULL)
return Z_MEM_ERROR; return Z_MEM_ERROR;

View File

@ -125,10 +125,8 @@
# define zng_uncompress2 @ZLIB_SYMBOL_PREFIX@zng_uncompress2 # define zng_uncompress2 @ZLIB_SYMBOL_PREFIX@zng_uncompress2
#endif #endif
#define zng_zError @ZLIB_SYMBOL_PREFIX@zng_zError #define zng_zError @ZLIB_SYMBOL_PREFIX@zng_zError
#ifndef Z_SOLO #define zng_zcalloc @ZLIB_SYMBOL_PREFIX@zng_zcalloc
# define zng_zcalloc @ZLIB_SYMBOL_PREFIX@zng_zcalloc #define zng_zcfree @ZLIB_SYMBOL_PREFIX@zng_zcfree
# define zng_zcfree @ZLIB_SYMBOL_PREFIX@zng_zcfree
#endif
#define zng_zlibCompileFlags @ZLIB_SYMBOL_PREFIX@zng_zlibCompileFlags #define zng_zlibCompileFlags @ZLIB_SYMBOL_PREFIX@zng_zlibCompileFlags
#define zng_zlibVersion @ZLIB_SYMBOL_PREFIX@zng_zlibVersion #define zng_zlibVersion @ZLIB_SYMBOL_PREFIX@zng_zlibVersion
@ -171,8 +169,6 @@
#define zng_zError @ZLIB_SYMBOL_PREFIX@zng_zError #define zng_zError @ZLIB_SYMBOL_PREFIX@zng_zError
#define zng_alloc_aligned @ZLIB_SYMBOL_PREFIX@zng_alloc_aligned #define zng_alloc_aligned @ZLIB_SYMBOL_PREFIX@zng_alloc_aligned
#define zng_calloc @ZLIB_SYMBOL_PREFIX@zng_calloc
#define zng_cfree @ZLIB_SYMBOL_PREFIX@zng_cfree
#define zng_free_aligned @ZLIB_SYMBOL_PREFIX@zng_free_aligned #define zng_free_aligned @ZLIB_SYMBOL_PREFIX@zng_free_aligned
#define zng_get_crc_table @ZLIB_SYMBOL_PREFIX@zng_get_crc_table #define zng_get_crc_table @ZLIB_SYMBOL_PREFIX@zng_get_crc_table
#define zng_inflateSyncPoint @ZLIB_SYMBOL_PREFIX@zng_inflateSyncPoint #define zng_inflateSyncPoint @ZLIB_SYMBOL_PREFIX@zng_inflateSyncPoint

View File

@ -165,8 +165,6 @@
/* zlib-ng specific symbols */ /* zlib-ng specific symbols */
#define zng_alloc_aligned @ZLIB_SYMBOL_PREFIX@zng_alloc_aligned #define zng_alloc_aligned @ZLIB_SYMBOL_PREFIX@zng_alloc_aligned
#define zng_calloc @ZLIB_SYMBOL_PREFIX@zng_calloc
#define zng_cfree @ZLIB_SYMBOL_PREFIX@zng_cfree
#define zng_free_aligned @ZLIB_SYMBOL_PREFIX@zng_free_aligned #define zng_free_aligned @ZLIB_SYMBOL_PREFIX@zng_free_aligned
#endif /* ZLIB_NAME_MANGLING_H */ #endif /* ZLIB_NAME_MANGLING_H */

12
zutil.c
View File

@ -100,12 +100,12 @@ const char * Z_EXPORT PREFIX(zError)(int err) {
return ERR_MSG(err); return ERR_MSG(err);
} }
void Z_INTERNAL *PREFIX3(calloc)(void *opaque, unsigned items, unsigned size) { void Z_INTERNAL *PREFIX(zcalloc)(void *opaque, unsigned items, unsigned size) {
Z_UNUSED(opaque); Z_UNUSED(opaque);
return zng_alloc((size_t)items * (size_t)size); return zng_alloc((size_t)items * (size_t)size);
} }
void Z_INTERNAL PREFIX3(cfree)(void *opaque, void *ptr) { void Z_INTERNAL PREFIX(zcfree)(void *opaque, void *ptr) {
Z_UNUSED(opaque); Z_UNUSED(opaque);
zng_free(ptr); zng_free(ptr);
} }
@ -118,8 +118,8 @@ void Z_INTERNAL *PREFIX3(alloc_aligned)(zng_calloc_func zalloc, void *opaque, un
void *ptr; void *ptr;
/* If no custom calloc function used then call zlib-ng's aligned calloc */ /* If no custom calloc function used then call zlib-ng's aligned calloc */
if (zalloc == PREFIX3(calloc)) if (zalloc == PREFIX(zcalloc))
return PREFIX3(calloc)(opaque, items, size); return PREFIX(zcalloc)(opaque, items, size);
/* Allocate enough memory for proper alignment and to store the original memory pointer */ /* Allocate enough memory for proper alignment and to store the original memory pointer */
alloc_size = sizeof(void *) + (items * size) + align; alloc_size = sizeof(void *) + (items * size) + align;
@ -143,8 +143,8 @@ void Z_INTERNAL *PREFIX3(alloc_aligned)(zng_calloc_func zalloc, void *opaque, un
void Z_INTERNAL PREFIX3(free_aligned)(zng_cfree_func zfree, void *opaque, void *ptr) { void Z_INTERNAL PREFIX3(free_aligned)(zng_cfree_func zfree, void *opaque, void *ptr) {
/* If no custom cfree function used then call zlib-ng's aligned cfree */ /* If no custom cfree function used then call zlib-ng's aligned cfree */
if (zfree == PREFIX3(cfree)) { if (zfree == PREFIX(zcfree)) {
PREFIX3(cfree)(opaque, ptr); PREFIX(zcfree)(opaque, ptr);
return; return;
} }
if (!ptr) if (!ptr)

View File

@ -126,8 +126,8 @@ extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */
/* memory allocation functions */ /* memory allocation functions */
void Z_INTERNAL *PREFIX3(calloc)(void *opaque, unsigned items, unsigned size); void Z_INTERNAL *PREFIX(zcalloc)(void *opaque, unsigned items, unsigned size);
void Z_INTERNAL PREFIX3(cfree)(void *opaque, void *ptr); void Z_INTERNAL PREFIX(zcfree)(void *opaque, void *ptr);
typedef void *zng_calloc_func(void *opaque, unsigned items, unsigned size); typedef void *zng_calloc_func(void *opaque, unsigned items, unsigned size);
typedef void zng_cfree_func(void *opaque, void *ptr); typedef void zng_cfree_func(void *opaque, void *ptr);