|
Graphviz 14.0.3~dev.20251104.0241
|
Implementation of the arena.h API. More...
#include <assert.h>#include <stdbool.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include <util/alloc.h>#include <util/arena.h>#include <util/asan.h>#include <util/unused.h>Go to the source code of this file.
Data Structures | |
| struct | arena_chunk |
Functions | |
| static UNUSED bool | is_power_of_2 (size_t value) |
popcount(value) == 1? | |
| static void | more_core (arena_t *arena, size_t req_alignment, size_t req_size) |
| static void * | alloc (arena_t *arena, size_t alignment, size_t size) |
| void * | gv_arena_alloc (arena_t *arena, size_t alignment, size_t size) |
| char * | gv_arena_strdup (arena_t *arena, const char *s) |
| void | gv_arena_free (arena_t *arena, void *ptr, size_t size) |
| void | gv_arena_reset (arena_t *arena) |
|
static |
allocate new dynamic memory
| arena | Arena to allocate from |
| alignment | Requested alignment |
| size | Requested size in bytes |
NULL on failure Definition at line 71 of file arena.c.
References ASAN_UNPOISON, is_power_of_2(), NULL, arena_t::remaining, and arena_t::source.
Referenced by gv_arena_alloc().
| void * gv_arena_alloc | ( | arena_t * | arena, |
| size_t | alignment, | ||
| size_t | size | ||
| ) |
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().
| void gv_arena_free | ( | arena_t * | arena, |
| void * | ptr, | ||
| size_t | size | ||
| ) |
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 endpoint(), prformat(), and scformat().
| void gv_arena_reset | ( | arena_t * | arena | ) |
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().
| char * gv_arena_strdup | ( | arena_t * | arena, |
| const char * | s | ||
| ) |
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().
|
static |
|
static |
get some more memory from the system allocator
| arena | Arena to install the new memory into |
| req_alignment | Alignment request that led to this call |
| req_size | Size request that led to this call |
Definition at line 38 of file arena.c.
References ASAN_POISON, gv_alloc(), NULL, arena_chunk::previous, arena_t::remaining, and arena_t::source.
Referenced by gv_arena_alloc().