|
memory_arena
|
Internal helpers for teardown and memory release. More...
Collaboration diagram for Arena Cleanup Internals:Functions | |
| static void | arena_free_buffer_if_owned (t_arena *arena) |
| Free the arena's internal buffer if the arena owns it. | |
| static void | arena_free_growth_history (t_arena *arena) |
| Free the memory used to store the arena's growth history. | |
Internal helpers for teardown and memory release.
|
inlinestatic |
#include <arena_cleanup.c>
Free the arena's internal buffer if the arena owns it.
This internal helper checks the owns_buffer atomic flag to determine whether the arena is responsible for freeing its memory buffer. If ownership is confirmed and the buffer is non-null, the function:
arena_poison_memory() for debugging.free().owns_buffer flag atomically to prevent double-free.This function is typically used during cleanup routines such as arena_destroy() to safely deallocate memory only if it was dynamically allocated by the arena itself.
| arena | Pointer to the arena whose buffer should be conditionally freed. |
Definition at line 186 of file arena_cleanup.c.
References arena_poison_memory.
|
inlinestatic |
#include <arena_cleanup.c>
Free the memory used to store the arena's growth history.
This internal helper checks whether the arena has recorded any growth history via the growth_history pointer in its stats. If so, it:
growth_history array.NULL to prevent dangling access.This function is called during teardown (e.g., in arena_destroy) to release dynamically allocated metadata associated with growth tracking.
| arena | Pointer to the arena whose growth history should be freed. |
Definition at line 221 of file arena_cleanup.c.
References arena_poison_memory.