#include <alloca.h>
#include <string.h>
#include "defs.h"
Go to the source code of this file.
|
struct | allocator_t |
| 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...
|
|
|
typedef void * | allocator_ptr |
| Opaque type-erased pointer to an allocator. Carries no value other than marking an argument to the function as being a type-erased allocator.
|
|
typedef void *() | mem_alloc_f(allocator_ptr allocator, sz size) |
| Allocate size bytes using the allocator
|
|
typedef void *() | mem_realloc_f(allocator_ptr allocator, void *memory, sz new_size) |
| Reallocate the memory at memory to a new location with.
|
|
typedef void() | mem_free_f(allocator_ptr allocator, void *memory) |
| Give up the ownership of the memory within the allocator .
|
|
typedef struct allocator_t | allocator_t |
| 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.
|
|
◆ poison_memory_region
#define poison_memory_region |
( |
|
ptr, |
|
|
|
sz |
|
) |
| |
If compiled with a memory sanitizer, any write to the brief selected memory will crash the program. If applied multiple times will still only be lifted once. Idempotent. Pair of unpoison_memory_region. O(1)
◆ unpoison_memory_region
#define unpoison_memory_region |
( |
|
ptr, |
|
|
|
sz |
|
) |
| |
◆ allocator_ptr
Opaque type-erased pointer to an allocator. Carries no value other than marking an argument to the function as being a type-erased allocator.
◆ allocator_t
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.
◆ mem_alloc_f
Allocate size
bytes using the allocator
◆ mem_free_f
Give up the ownership of the memory
within the allocator
.
◆ mem_realloc_f
typedef void *() mem_realloc_f(allocator_ptr allocator, void *memory, sz new_size) |
Reallocate the memory at memory
to a new location with.
◆ alloc_stack_alloc__alloc()
static void * alloc_stack_alloc__alloc |
( |
allocator_ptr |
allocator, |
|
|
sz |
new_size |
|
) |
| |
|
static |
◆ allocator_new_malloc()
Wrap malloc
into an generic allocator interface.
◆ allocator_new_stack_alloc()