Merge commit 'ee861bc6cf7ccec4a056443488e7b0860b8b0606' as 'external/unarr'
This commit is contained in:
29
external/unarr/common/allocator.h
vendored
Normal file
29
external/unarr/common/allocator.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/* 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
|
||||
Reference in New Issue
Block a user