File indexing completed on 2025-02-02 04:25:58
0001 /* Copyright 2015 the unarr project authors (see AUTHORS file). 0002 License: LGPLv3 */ 0003 0004 #ifndef common_allocator_h 0005 #define common_allocator_h 0006 0007 #ifdef USE_CUSTOM_ALLOCATOR 0008 0009 #include <stddef.h> 0010 0011 typedef void *(* custom_malloc_fn)(void *opaque, size_t size); 0012 typedef void (* custom_free_fn)(void *opaque, void *ptr); 0013 0014 void ar_set_custom_allocator(custom_malloc_fn custom_malloc, custom_free_fn custom_free, void *opaque); 0015 0016 #define malloc(size) ar_malloc(size) 0017 #define calloc(count, size) ar_calloc(count, size) 0018 #define free(ptr) ar_free(ptr) 0019 0020 #define realloc(ptr, size) _use_malloc_memcpy_free_instead(ptr, size) 0021 #define strdup(str) _use_malloc_memcpy_instead(str) 0022 0023 #elif !defined(NDEBUG) && defined(_MSC_VER) 0024 0025 #include <crtdbg.h> 0026 0027 #endif 0028 0029 #endif