Subastra
|
A generic allocator type passed by value. Contains a fallback allocator and a set of function pointers for managing memory. Erases the type of the internal allocator. More...
#include <memory.h>
Public Member Functions | |
#define | allocator_alloc_ty(ty, allocator, sz) (ty *)allocator_alloc(allocator, sizeof(ty) * sz) |
Allocate a typed buffer of size sz using allocator . | |
#define | allocator_alloc_copy_ty(ty, allocator, data, sz) (ty *)allocator_alloc_copy(allocator, data, sizeof(ty) * sz) |
Copy sz typedef elements of data from data into a freshly allocated slice using the allocator . | |
Static Public Member Functions | |
static void * | allocator_alloc (allocator_t allocator, sz size) |
Proxy the allocation to the actual allocator. | |
static void * | allocator_alloc_copy (allocator_t allocator, const void *data, sz size) |
Copy size bytes of data from data into a freshly allocated slice using the allocator . | |
static void * | allocator_realloc (allocator_t allocator, void *memory, sz size) |
Move memory to a new memory region with at least size bytes. If an allocator does not implement realloc it will be polyfilled. | |
static void | allocator_free (allocator_t allocator, void *memory) |
Release memory back to the allocator. | |
Data Fields | |
allocator_ptr | allocator |
A pointer to the actual underyling allocator, type-erased. | |
mem_alloc_f * | alloc |
mem_realloc_f * | realloc |
mem_free_f * | free |
A generic allocator type passed by value. Contains a fallback allocator and a set of function pointers for managing memory. Erases the type of the internal allocator.
|
inlinestatic |
Proxy the allocation to the actual allocator.
|
inlinestatic |
Copy size
bytes of data from data
into a freshly allocated slice using the allocator
.
|
inlinestatic |
Release memory
back to the allocator.
|
inlinestatic |
Move memory
to a new memory region with at least size
bytes. If an allocator does not implement realloc
it will be polyfilled.
mem_alloc_f* alloc |
allocator_ptr allocator |
A pointer to the actual underyling allocator, type-erased.
mem_free_f* free |
mem_realloc_f* realloc |