From d31e119d4dc678fe2a7e3e314668ecc82eeadaef Mon Sep 17 00:00:00 2001 From: Dmitry Eremin-Solenikov Date: Thu, 17 Jan 2019 12:52:11 +0300 Subject: [PATCH] Move comp/decomp alloc/free prototypes under guarding #ifndef Function implemenations are already guarded by #ifndef MZ_NO_MALLOC, so let's put prototypes under the same #ifndef. Also, while we are at it, make those prototypes standard-compliant by adding void argument. Signed-off-by: Dmitry Eremin-Solenikov --- miniz_tdef.c | 2 ++ miniz_tdef.h | 4 +++- miniz_tinfl.c | 2 ++ miniz_tinfl.h | 5 +++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/miniz_tdef.c b/miniz_tdef.c index a2c638a..a8a9593 100644 --- a/miniz_tdef.c +++ b/miniz_tdef.c @@ -1555,6 +1555,7 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE); } +#ifndef MINIZ_NO_MALLOC /* Allocate the tdefl_compressor and tinfl_decompressor structures in C so that */ /* non-C language bindings to tdefL_ and tinfl_ API don't need to worry about */ /* structure size and allocation mechanism. */ @@ -1567,6 +1568,7 @@ void tdefl_compressor_free(tdefl_compressor *pComp) { MZ_FREE(pComp); } +#endif #ifdef _MSC_VER #pragma warning(pop) diff --git a/miniz_tdef.h b/miniz_tdef.h index efcb5ea..afa535c 100644 --- a/miniz_tdef.h +++ b/miniz_tdef.h @@ -177,11 +177,13 @@ mz_uint32 tdefl_get_adler32(tdefl_compressor *d); /* strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED */ mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy); +#ifndef MINIZ_NO_MALLOC /* Allocate the tdefl_compressor structure in C so that */ /* non-C language bindings to tdefl_ API don't need to worry about */ /* structure size and allocation mechanism. */ -tdefl_compressor *tdefl_compressor_alloc(); +tdefl_compressor *tdefl_compressor_alloc(void); void tdefl_compressor_free(tdefl_compressor *pComp); +#endif #ifdef __cplusplus } diff --git a/miniz_tinfl.c b/miniz_tinfl.c index 3acf56b..5120ba1 100644 --- a/miniz_tinfl.c +++ b/miniz_tinfl.c @@ -720,6 +720,7 @@ int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, return result; } +#ifndef MINIZ_NO_MALLOC tinfl_decompressor *tinfl_decompressor_alloc() { tinfl_decompressor *pDecomp = (tinfl_decompressor *)MZ_MALLOC(sizeof(tinfl_decompressor)); @@ -732,6 +733,7 @@ void tinfl_decompressor_free(tinfl_decompressor *pDecomp) { MZ_FREE(pDecomp); } +#endif #ifdef __cplusplus } diff --git a/miniz_tinfl.h b/miniz_tinfl.h index 8cb8cda..be4ec9c 100644 --- a/miniz_tinfl.h +++ b/miniz_tinfl.h @@ -41,12 +41,13 @@ int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, struct tinfl_decompressor_tag; typedef struct tinfl_decompressor_tag tinfl_decompressor; +#ifndef MINIZ_NO_MALLOC /* Allocate the tinfl_decompressor structure in C so that */ /* non-C language bindings to tinfl_ API don't need to worry about */ /* structure size and allocation mechanism. */ - -tinfl_decompressor *tinfl_decompressor_alloc(); +tinfl_decompressor *tinfl_decompressor_alloc(void); void tinfl_decompressor_free(tinfl_decompressor *pDecomp); +#endif /* Max size of LZ dictionary. */ #define TINFL_LZ_DICT_SIZE 32768