mirror of
https://github.com/GerbilSoft/zlib-ng.git
synced 2025-06-18 19:45:37 -04:00
Fix prefixing for internal functions calloc/cfree
This commit is contained in:
parent
6c09fa2613
commit
cf5bb01da9
@ -202,11 +202,11 @@ int32_t ZNG_CONDEXPORT PREFIX(deflateInit2)(PREFIX3(stream) *strm, int32_t level
|
||||
|
||||
strm->msg = NULL;
|
||||
if (strm->zalloc == NULL) {
|
||||
strm->zalloc = PREFIX3(calloc);
|
||||
strm->zalloc = PREFIX(zcalloc);
|
||||
strm->opaque = NULL;
|
||||
}
|
||||
if (strm->zfree == NULL)
|
||||
strm->zfree = PREFIX3(cfree);
|
||||
strm->zfree = PREFIX(zcfree);
|
||||
|
||||
if (level == Z_DEFAULT_COMPRESSION)
|
||||
level = 6;
|
||||
|
@ -38,11 +38,11 @@ int32_t ZNG_CONDEXPORT PREFIX(inflateBackInit)(PREFIX3(stream) *strm, int32_t wi
|
||||
return Z_STREAM_ERROR;
|
||||
strm->msg = NULL; /* in case we return an error */
|
||||
if (strm->zalloc == NULL) {
|
||||
strm->zalloc = PREFIX3(calloc);
|
||||
strm->zalloc = PREFIX(zcalloc);
|
||||
strm->opaque = NULL;
|
||||
}
|
||||
if (strm->zfree == NULL)
|
||||
strm->zfree = PREFIX3(cfree);
|
||||
strm->zfree = PREFIX(zcfree);
|
||||
state = ZALLOC_INFLATE_STATE(strm);
|
||||
if (state == NULL)
|
||||
return Z_MEM_ERROR;
|
||||
|
@ -146,11 +146,11 @@ int32_t ZNG_CONDEXPORT PREFIX(inflateInit2)(PREFIX3(stream) *strm, int32_t windo
|
||||
return Z_STREAM_ERROR;
|
||||
strm->msg = NULL; /* in case we return an error */
|
||||
if (strm->zalloc == NULL) {
|
||||
strm->zalloc = PREFIX3(calloc);
|
||||
strm->zalloc = PREFIX(zcalloc);
|
||||
strm->opaque = NULL;
|
||||
}
|
||||
if (strm->zfree == NULL)
|
||||
strm->zfree = PREFIX3(cfree);
|
||||
strm->zfree = PREFIX(zcfree);
|
||||
state = ZALLOC_INFLATE_STATE(strm);
|
||||
if (state == NULL)
|
||||
return Z_MEM_ERROR;
|
||||
|
@ -125,10 +125,8 @@
|
||||
# define zng_uncompress2 @ZLIB_SYMBOL_PREFIX@zng_uncompress2
|
||||
#endif
|
||||
#define zng_zError @ZLIB_SYMBOL_PREFIX@zng_zError
|
||||
#ifndef Z_SOLO
|
||||
#define zng_zcalloc @ZLIB_SYMBOL_PREFIX@zng_zcalloc
|
||||
#define zng_zcfree @ZLIB_SYMBOL_PREFIX@zng_zcfree
|
||||
#endif
|
||||
#define zng_zlibCompileFlags @ZLIB_SYMBOL_PREFIX@zng_zlibCompileFlags
|
||||
#define zng_zlibVersion @ZLIB_SYMBOL_PREFIX@zng_zlibVersion
|
||||
|
||||
@ -171,8 +169,6 @@
|
||||
#define zng_zError @ZLIB_SYMBOL_PREFIX@zng_zError
|
||||
|
||||
#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_get_crc_table @ZLIB_SYMBOL_PREFIX@zng_get_crc_table
|
||||
#define zng_inflateSyncPoint @ZLIB_SYMBOL_PREFIX@zng_inflateSyncPoint
|
||||
|
@ -165,8 +165,6 @@
|
||||
|
||||
/* zlib-ng specific symbols */
|
||||
#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
|
||||
|
||||
#endif /* ZLIB_NAME_MANGLING_H */
|
||||
|
12
zutil.c
12
zutil.c
@ -100,12 +100,12 @@ const char * Z_EXPORT PREFIX(zError)(int 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);
|
||||
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);
|
||||
zng_free(ptr);
|
||||
}
|
||||
@ -118,8 +118,8 @@ void Z_INTERNAL *PREFIX3(alloc_aligned)(zng_calloc_func zalloc, void *opaque, un
|
||||
void *ptr;
|
||||
|
||||
/* If no custom calloc function used then call zlib-ng's aligned calloc */
|
||||
if (zalloc == PREFIX3(calloc))
|
||||
return PREFIX3(calloc)(opaque, items, size);
|
||||
if (zalloc == PREFIX(zcalloc))
|
||||
return PREFIX(zcalloc)(opaque, items, size);
|
||||
|
||||
/* Allocate enough memory for proper alignment and to store the original memory pointer */
|
||||
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) {
|
||||
/* If no custom cfree function used then call zlib-ng's aligned cfree */
|
||||
if (zfree == PREFIX3(cfree)) {
|
||||
PREFIX3(cfree)(opaque, ptr);
|
||||
if (zfree == PREFIX(zcfree)) {
|
||||
PREFIX(zcfree)(opaque, ptr);
|
||||
return;
|
||||
}
|
||||
if (!ptr)
|
||||
|
4
zutil.h
4
zutil.h
@ -126,8 +126,8 @@ extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */
|
||||
|
||||
/* memory allocation functions */
|
||||
|
||||
void Z_INTERNAL *PREFIX3(calloc)(void *opaque, unsigned items, unsigned size);
|
||||
void Z_INTERNAL PREFIX3(cfree)(void *opaque, void *ptr);
|
||||
void Z_INTERNAL *PREFIX(zcalloc)(void *opaque, unsigned items, unsigned size);
|
||||
void Z_INTERNAL PREFIX(zcfree)(void *opaque, void *ptr);
|
||||
|
||||
typedef void *zng_calloc_func(void *opaque, unsigned items, unsigned size);
|
||||
typedef void zng_cfree_func(void *opaque, void *ptr);
|
||||
|
Loading…
Reference in New Issue
Block a user