|
memory_arena
|
Internal helpers for configuring sub-arenas. More...
Collaboration diagram for Sub-Arena Internals:Functions | |
| static bool | arena_alloc_sub_validate (t_arena *parent, t_arena *child) |
| Validate the input parameters for creating a sub-arena. | |
| static void | arena_generate_subarena_id (t_arena *parent, t_arena *child) |
| Generate a unique debug identifier for a sub-arena. | |
| static void | arena_setup_subarena (t_arena *parent, t_arena *child, void *buffer, size_t size, const char *label) |
| Initialize a child arena as a sub-arena of a parent using a provided memory block. | |
Internal helpers for configuring sub-arenas.
#include <arena_alloc_sub.c>
Validate the input parameters for creating a sub-arena.
This internal function ensures that both parent and child arena pointers are valid before proceeding with a sub-arena allocation. It performs:
parent pointer's address to ensure it isn't accidentally an invalid pointer (e.g., very low memory address).If validation fails, an appropriate error is reported via arena_report_error().
| parent | Pointer to the parent arena from which memory will be allocated. |
| child | Pointer to the arena struct that will be initialized as a sub-arena. |
true if both parameters are valid, false otherwise.Definition at line 446 of file arena_alloc_sub.c.
References arena_report_error().
#include <arena_alloc_sub.c>
Generate a unique debug identifier for a sub-arena.
This internal helper constructs a human-readable ID string for a child (sub-arena), based on its parent arena's ID. The generated ID takes the form:
`<PREF>.<N>`
Where <PREF> is the first four characters of the parent arena's ID and <N> is an incrementing counter (subarena index). This ID is stored in child->debug.id and can be used in logs, debug tools, or allocation tracking.
The parent's subarena counter is incremented after each call.
| parent | Pointer to the parent arena. |
| child | Pointer to the child arena to assign the ID. |
ARENA_ID_LEN if the formatted string exceeds the limit.Definition at line 532 of file arena_alloc_sub.c.
References ARENA_ID_LEN.
|
inlinestatic |
#include <arena_alloc_sub.c>
Initialize a child arena as a sub-arena of a parent using a provided memory block.
This internal helper prepares a child arena to operate as a sub-arena carved from its parent. It performs the following steps:
child using arena_init_with_buffer() with the given buffer and size.child->parent_ref."subarena" if label == NULL).ARENA_CHECK().This function assumes that the memory buffer was already allocated from the parent arena.
| parent | Pointer to the parent arena. |
| child | Pointer to the arena to be configured as a sub-arena. |
| buffer | Memory block allocated from the parent to back the child arena. |
| size | Size of the memory block in bytes. |
| label | Optional debug label for the sub-arena. Can be NULL. |
child to use memory previously allocated from the parent.Definition at line 493 of file arena_alloc_sub.c.
References ARENA_CHECK, arena_generate_subarena_id(), arena_init_with_buffer(), and arena_set_debug_label().