|
cbase 1.50.0
C/C++ Static Template
|
Generic interface for abstracting memory allocators. More...


Go to the source code of this file.
Classes | |
| struct | MemAllocator |
| An abstract allocator interface. More... | |
Macros | |
| #define | MAKE(type, count, alloc) |
Allocates and zero-initialises an array of count elements of type. | |
| #define | MAKE_STRUCT(type, alloc) |
Allocates and zero-initialises a single instance of type. | |
| #define | RELEASE(type, count, ptr, alloc) |
| Frees a previously allocated block through the allocator. | |
Typedefs | |
| typedef enum MemAllocMode | MemAllocMode |
| Describes the type of memory operation being requested. | |
| typedef void *(* | MemAllocFn) (MemAllocMode mode, void *ctx, usize size, void *old_ptr) |
| The core function signature for an abstract allocator. | |
| typedef struct MemAllocator | MemAllocator |
| An abstract allocator interface. | |
Enumerations | |
| enum | MemAllocMode { MEM_ALLOC_MODE_ALLOC , MEM_ALLOC_MODE_FREE , MEM_ALLOC_MODE_REALLOC , MEM_ALLOC_MODE_FREE_ALL } |
| Describes the type of memory operation being requested. More... | |
Functions | |
| function void * | mem_alloc (MemAllocator *alloc, usize size) |
| Allocator Helper Functions. | |
| function void * | mem_realloc (MemAllocator *alloc, void *old_ptr, usize old_size, usize new_size) |
| Resizes a previously allocated block through the allocator. | |
| function void | mem_free (MemAllocator *alloc, void *ptr, usize size) |
| Frees a previously allocated block through the allocator. | |
| function void | mem_free_all (MemAllocator *alloc) |
| Clears the entire allocator in one shot (e.g. arena reset, pool reset). | |
Generic interface for abstracting memory allocators.
Allows data structures to accept a generic allocator interface rather than hardcoding a dependency on an Arena or General Purpose Allocator. Code that takes a MemAllocator works with any backing allocator without recompilation.
Definition in file mem_allocator.h.