Graphviz 13.1.3~dev.20250813.2319
|
Region-based memory allocator. More...
Go to the source code of this file.
Data Structures | |
struct | arena_t |
Macros | |
#define | ARENA_NEW(arena, type) gv_arena_alloc((arena), alignof(type), sizeof(type)) |
Typedefs | |
typedef struct arena_chunk | arena_chunk_t |
Functions | |
UTIL_API void * | gv_arena_alloc (arena_t *arena, size_t alignment, size_t size) |
UTIL_API char * | gv_arena_strdup (arena_t *arena, const char *s) |
UTIL_API void | gv_arena_free (arena_t *arena, void *ptr, size_t size) |
UTIL_API void | gv_arena_reset (arena_t *arena) |
The API below is for interacting with a basic bump-pointer allocator.¹
¹ https://en.wikipedia.org/wiki/Region-based_memory_management
Definition in file arena.h.
#define ARENA_NEW | ( | arena, | |
type | |||
) | gv_arena_alloc((arena), alignof(type), sizeof(type)) |
allocate new memory for a typed value
This is shorthand for when you are allocating memory for a specific type. The returned memory is zero initialized.
arena | Arena to allocate from |
type | Type of value that will be later stored in this memory |
typedef struct arena_chunk arena_chunk_t |
allocate new memory
The requested alignment
must be a power of two. The returned memory is zero initialized.
arena | Arena to allocate from |
alignment | Required pointer alignment for the resulting allocation |
size | Number of bytes requested |
Definition at line 116 of file arena.c.
References alloc(), more_core(), and NULL.
Referenced by eval(), exprintf(), exsplit(), exstralloc(), exsubstr(), extoken_fn(), extokens(), getdyn(), gv_arena_strdup(), prformat(), scformat(), str_add(), str_and(), str_ior(), str_mod(), str_mpy(), and str_xor().
deallocate memory
arena | Arena that was previously used to allocate this memory |
ptr | Pointer to memory to release |
size | Number of bytes of the original allocation |
Definition at line 147 of file arena.c.
References ASAN_POISON, and NULL.
Referenced by prformat(), and scformat().
deallocate all memory
Calling this restores the arena to an empty state from which it can be used for more allocations.
arena | Arena to reset |
Definition at line 162 of file arena.c.
References free(), NULL, arena_chunk::previous, and arena_t::source.
Referenced by ELcleanup().
copy a string into new dynamic memory
arena | Arena to allocate from |
s | Source string to copy |
Definition at line 134 of file arena.c.
References gv_arena_alloc(), len(), and NULL.
Referenced by eval(), exstring(), exsub(), extoken_fn(), and prformat().