memory_arena
Loading...
Searching...
No Matches
Functions
arena_stack.c File Reference

Stack-based scoped memory management for arenas. More...

#include "arena_stack.h"
#include <stdlib.h>
+ Include dependency graph for arena_stack.c:

Go to the source code of this file.

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.
 

Detailed Description

Stack-based scoped memory management for arenas.

Author
Toonsa
Date
2025

This module implements a lightweight stack system on top of arena-based memory. It allows users to push and pop memory states using marker frames allocated within the arena itself. This pattern enables efficient and structured management of temporary memory regions.

Core functionality includes:

All stack frames are stored inside the arena, meaning no additional heap allocations or deallocations are required.

Typical use cases:

Note
Stack operations (push, pop, clear) are local to the arena and safe to use as long as the arena is not destroyed or reset externally.

Definition in file arena_stack.c.