Allow compiling with custom allocators

User can define hb_malloc_impl, etc, to name of custom allocator functions
that have the same signature as malloc.
This commit is contained in:
Behdad Esfahbod 2015-10-03 13:20:55 +01:00
parent 88da7bba9f
commit 52b418555b
1 changed files with 17 additions and 0 deletions

View File

@ -54,6 +54,23 @@
#include <stdarg.h>
/* Compile-time custom allocator support. */
#if defined(hb_malloc_impl) \
&& defined(hb_calloc_impl) \
&& defined(hb_realloc_impl) \
&& defined(hb_free_impl)
extern void* hb_malloc_impl(size_t size);
extern void* hb_calloc_impl(size_t nmemb, size_t size);
extern void* hb_realloc_impl(void *ptr, size_t size);
extern void hb_free_impl(void *ptr);
#define malloc hb_malloc_impl
#define calloc hb_calloc_impl
#define realloc hb_realloc_impl
#define free hb_free_impl
#endif
/* Compiler attributes */