19#define TOY_GROW_CAPACITY(capacity) ((capacity) < 8 ? 8 : (capacity) * 2)
26#define TOY_GROW_CAPACITY_FAST(capacity) ((capacity) < 32 ? 32 : (capacity) * 2)
34#define TOY_ALLOCATE(type, count) ((type*)Toy_reallocate(NULL, 0, sizeof(type) * (count)))
41#define TOY_FREE(type, pointer) Toy_reallocate(pointer, sizeof(type), 0)
48#define TOY_FREE_ARRAY(type, pointer, oldCount) Toy_reallocate((type*)pointer, sizeof(type) * (oldCount), 0)
55#define TOY_GROW_ARRAY(type, pointer, oldCount, count) (type*)Toy_reallocate((type*)pointer, sizeof(type) * (oldCount), sizeof(type) * (count))
63#define TOY_SHRINK_ARRAY(type, pointer, oldCount, count) (type*)Toy_reallocate((type*)pointer, sizeof(type) * (oldCount), sizeof(type) * (count))
92typedef void* (*Toy_MemoryAllocatorFn)(
void *pointer,
size_t oldSize,
size_t newSize);
void *(* Toy_MemoryAllocatorFn)(void *pointer, size_t oldSize, size_t newSize)
This function interface is used for defining any memory allocator functions. Any and all memory alloc...
Definition: toy_memory.h:92
TOY_API void Toy_setMemoryAllocator(Toy_MemoryAllocatorFn)
Sets the memory allocator, replacing the default memory allocator. This function also overwrites any ...
TOY_API void * Toy_reallocate(void *pointer, size_t oldSize, size_t newSize)
Wraps a call to the internal assigned memory allocator. This function shouldn't be called directly....