Added custom allocator support

This commit is contained in:
2022-11-19 08:18:45 +00:00
parent 0b57f7efe7
commit 4518b59417
4 changed files with 75 additions and 9 deletions

View File

@@ -10,5 +10,8 @@
#define SHRINK_ARRAY(type, pointer, oldCount, count) (type*)reallocate((type*)pointer, sizeof(type) * (oldCount), sizeof(type) * (count))
#define FREE_ARRAY(type, pointer, oldCount) reallocate((type*)pointer, sizeof(type) * (oldCount), 0)
void* reallocate(void* pointer, size_t oldSize, size_t newSize);
//implementation details
typedef void* (*AllocatorFn)(void* pointer, size_t oldSize, size_t newSize);
void setAllocator(AllocatorFn);
void* reallocate(void* pointer, size_t oldSize, size_t newSize);