From 66bd59c4be1befb2a1b9d4b83d339c373dca4e63 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 2 Apr 2020 23:49:00 -0700 Subject: [PATCH] lib: rename the aligned allocation functions In preparation for adding libdeflate_malloc() and libdeflate_free(), rename the aligned allocation functions to match. --- lib/deflate_compress.c | 6 +++--- lib/lib_common.h | 12 +++++------- lib/utils.c | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/deflate_compress.c b/lib/deflate_compress.c index e3fac43..5527078 100644 --- a/lib/deflate_compress.c +++ b/lib/deflate_compress.c @@ -2681,7 +2681,7 @@ libdeflate_alloc_compressor(int compression_level) #endif size = offsetof(struct libdeflate_compressor, p) + sizeof(c->p.g); - c = aligned_malloc(MATCHFINDER_ALIGNMENT, size); + c = libdeflate_aligned_malloc(MATCHFINDER_ALIGNMENT, size); if (!c) return NULL; @@ -2765,7 +2765,7 @@ libdeflate_alloc_compressor(int compression_level) break; #endif default: - aligned_free(c); + libdeflate_aligned_free(c); return NULL; } @@ -2801,7 +2801,7 @@ libdeflate_deflate_compress(struct libdeflate_compressor *c, LIBDEFLATEEXPORT void LIBDEFLATEAPI libdeflate_free_compressor(struct libdeflate_compressor *c) { - aligned_free(c); + libdeflate_aligned_free(c); } unsigned int diff --git a/lib/lib_common.h b/lib/lib_common.h index 059c8ed..fb36dfc 100644 --- a/lib/lib_common.h +++ b/lib/lib_common.h @@ -15,9 +15,9 @@ #include "common_defs.h" /* - * Prefix with "_libdeflate_" all global symbols which are not part of the API. - * This avoids exposing overly generic names when libdeflate is built as a - * static library. + * Prefix with "_libdeflate_" all global symbols which are not part of the API + * and don't already have a "libdeflate" prefix. This avoids exposing overly + * generic names when libdeflate is built as a static library. * * Note that the chosen prefix is not really important and can be changed * without breaking library users. It was just chosen so that the resulting @@ -26,13 +26,11 @@ * shared library, since these symbols are not exported. */ #define SYM_FIXUP(sym) _libdeflate_##sym -#define aligned_malloc SYM_FIXUP(aligned_malloc) -#define aligned_free SYM_FIXUP(aligned_free) #define deflate_get_compression_level SYM_FIXUP(deflate_get_compression_level) #define _cpu_features SYM_FIXUP(_cpu_features) #define setup_cpu_features SYM_FIXUP(setup_cpu_features) -void *aligned_malloc(size_t alignment, size_t size); -void aligned_free(void *ptr); +void *libdeflate_aligned_malloc(size_t alignment, size_t size); +void libdeflate_aligned_free(void *ptr); #endif /* LIB_LIB_COMMON_H */ diff --git a/lib/utils.c b/lib/utils.c index 8916398..1e43b76 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -30,7 +30,7 @@ #include "lib_common.h" void * -aligned_malloc(size_t alignment, size_t size) +libdeflate_aligned_malloc(size_t alignment, size_t size) { void *ptr = malloc(sizeof(void *) + alignment - 1 + size); if (ptr) { @@ -42,7 +42,7 @@ aligned_malloc(size_t alignment, size_t size) } void -aligned_free(void *ptr) +libdeflate_aligned_free(void *ptr) { if (ptr) free(((void **)ptr)[-1]);