Files
kaizen/common/allocator.h
SimoneN64 ee861bc6cf Squashed 'external/unarr/' content from commit f243d72fb3
git-subtree-dir: external/unarr
git-subtree-split: f243d72fb3fe418c26a19514609ac7167d089df4
2024-09-14 16:23:23 +02:00

30 lines
743 B
C

/* Copyright 2015 the unarr project authors (see AUTHORS file).
License: LGPLv3 */
#ifndef common_allocator_h
#define common_allocator_h
#ifdef USE_CUSTOM_ALLOCATOR
#include <stddef.h>
typedef void *(* custom_malloc_fn)(void *opaque, size_t size);
typedef void (* custom_free_fn)(void *opaque, void *ptr);
void ar_set_custom_allocator(custom_malloc_fn custom_malloc, custom_free_fn custom_free, void *opaque);
#define malloc(size) ar_malloc(size)
#define calloc(count, size) ar_calloc(count, size)
#define free(ptr) ar_free(ptr)
#define realloc(ptr, size) _use_malloc_memcpy_free_instead(ptr, size)
#define strdup(str) _use_malloc_memcpy_instead(str)
#elif !defined(NDEBUG) && defined(_MSC_VER)
#include <crtdbg.h>
#endif
#endif