|
memory_arena
|
Functions for inspecting and manipulating arena usage state. More...
Files | |
| file | arena_stack.c |
| Stack-based scoped memory management for arenas. | |
| file | arena_stack.h |
| Stack-based scope management for memory arenas. | |
| file | arena_state.c |
| Arena state inspection and control utilities. | |
Data Structures | |
| struct | s_arena_stack |
| Stack structure for scoped arena memory control. More... | |
| struct | s_arena_stack_frame |
| Internal frame representing a single state snapshot in the stack. More... | |
Typedefs | |
| typedef struct s_arena_stack | t_arena_stack |
| Stack structure for scoped arena memory control. | |
| typedef struct s_arena_stack_frame | t_arena_stack_frame |
| Internal frame representing a single state snapshot in the stack. | |
Functions | |
| void | arena_stack_clear (t_arena_stack *stack) |
| Clear all stack frames without modifying arena state. | |
| void | arena_stack_init (t_arena_stack *stack, t_arena *arena) |
| Initialize an arena stack with a given arena. | |
| void | arena_stack_pop (t_arena_stack *stack) |
| Pop and restore the last saved state from the stack. | |
| void | arena_stack_push (t_arena_stack *stack) |
| Push the current arena state onto the stack. | |
Functions for inspecting and manipulating arena usage state.
These functions provide insight into memory usage (used, remaining, peak) and allow for scoped rollback (mark, pop) and reset operations.
| struct s_arena_stack |
Stack structure for scoped arena memory control.
Holds a pointer to an arena and a linked list of frames representing saved arena states. Frames are allocated from the arena itself.
Definition at line 70 of file arena_stack.h.
Collaboration diagram for s_arena_stack:| Data Fields | ||
|---|---|---|
| t_arena * | arena | Arena associated with this stack. |
| t_arena_stack_frame * | top | Top of the stack (most recent frame) |
| struct s_arena_stack_frame |
Internal frame representing a single state snapshot in the stack.
Each frame holds a marker (offset) representing the arena state at the time of push, and a pointer to the previous frame for LIFO traversal.
Definition at line 54 of file arena_stack.h.
Collaboration diagram for s_arena_stack_frame:| Data Fields | ||
|---|---|---|
| size_t | marker | Marker to rewind arena to this point. |
| struct s_arena_stack_frame * | prev | Previous frame in the stack. |
| typedef struct s_arena_stack t_arena_stack |
#include <arena_stack.h>
Stack structure for scoped arena memory control.
Holds a pointer to an arena and a linked list of frames representing saved arena states. Frames are allocated from the arena itself.
| typedef struct s_arena_stack_frame t_arena_stack_frame |
#include <arena_stack.h>
Internal frame representing a single state snapshot in the stack.
Each frame holds a marker (offset) representing the arena state at the time of push, and a pointer to the previous frame for LIFO traversal.
| void arena_stack_clear | ( | t_arena_stack * | stack | ) |
#include <arena_stack.h>
Clear all stack frames without modifying arena state.
Clear all frames in the arena stack without altering arena memory.
| stack | Pointer to the arena stack to clear. |
This function discards all frames from the arena stack by resetting the top pointer to NULL. It does not modify the arena’s allocation state or release memory. It's a logical reset of the stack structure, not a memory rollback.
Use this when:
| stack | Pointer to the arena stack to clear. |
arena_stack_pop() to actually revert memory state.arena_stack_push(). Use with care if frames are still expected to be restored.Definition at line 295 of file arena_stack.c.
References s_arena_stack::top.
| void arena_stack_init | ( | t_arena_stack * | stack, |
| t_arena * | arena | ||
| ) |
#include <arena_stack.h>
Initialize an arena stack with a given arena.
| stack | Pointer to the arena stack to initialize. |
| arena | Pointer to the arena the stack will manage. |
arena_stack_push() is called.Definition at line 144 of file arena_stack.c.
References s_arena_stack::arena, and s_arena_stack::top.
| void arena_stack_pop | ( | t_arena_stack * | stack | ) |
#include <arena_stack.h>
Pop and restore the last saved state from the stack.
Restores the arena to the previous state (marker) and discards all allocations made since the last arena_stack_push() call.
| stack | Pointer to the arena stack to pop from. |
Definition at line 254 of file arena_stack.c.
References s_arena_stack::arena, arena_pop(), s_arena_stack_frame::marker, s_arena_stack_frame::prev, and s_arena_stack::top.
| void arena_stack_push | ( | t_arena_stack * | stack | ) |
#include <arena_stack.h>
Push the current arena state onto the stack.
Saves the current allocation offset into a new stack frame. All allocations made after the push can later be discarded with arena_stack_pop().
| stack | Pointer to the arena stack to push onto. |
Definition at line 197 of file arena_stack.c.
References s_arena_stack::arena, arena_alloc(), arena_mark(), s_arena_stack_frame::marker, s_arena_stack_frame::prev, and s_arena_stack::top.