|
cbase 1.46.11
C/C++ Static Template
|
Generic allocator interface (vtable) for polymorphic memory allocation. More...


Go to the source code of this file.
Classes | |
| struct | Allocator |
| A generic allocator backed by function pointers (vtable). More... | |
Typedefs | |
| typedef void *(* | AllocFn) (void *ctx, usize size) |
| Function pointer type for an allocation operation. | |
| typedef void(* | FreeFn) (void *ctx, void *ptr, usize size) |
| Function pointer type for a free operation. | |
| typedef void *(* | ReallocFn) (void *ctx, void *ptr, usize old_size, usize new_size) |
| Function pointer type for a realloc operation. | |
| typedef struct Allocator | Allocator |
| A generic allocator backed by function pointers (vtable). | |
Functions | |
| function void * | allocator_alloc (Allocator *a, usize size) |
| Allocates size zero-initialized bytes through the allocator. | |
| function void | allocator_free (Allocator *a, void *ptr, usize size) |
| Frees a previously allocated block through the allocator. | |
| function void * | allocator_realloc (Allocator *a, void *ptr, usize old_size, usize new_size) |
| Resizes a previously allocated block through the allocator. | |
| function Allocator | arena_allocator (Arena *arena) |
| Constructs an Allocator interface backed by an existing Arena. | |
Generic allocator interface (vtable) for polymorphic memory allocation.
Defines a lightweight Allocator struct whose function pointers can be backed by any allocator implementation (Arena, heap, pool, etc.). Code that accepts an Allocator by value is automatically compatible with every allocator in the project without a recompile.
Definition in file mem_allocator.h.