mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-09-08 03:39:25 -04:00
lib: rename the aligned allocation functions
In preparation for adding libdeflate_malloc() and libdeflate_free(), rename the aligned allocation functions to match.
This commit is contained in:
parent
64b4e8191e
commit
66bd59c4be
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user