memory_arena
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
Scratch Arena Internals

Internal helpers and utilities for scratch arena pool management. More...

+ Collaboration diagram for Scratch Arena Internals:

Data Structures

struct  s_scratch_slot
 Represents a single slot in the scratch arena pool. More...
 

Typedefs

typedef struct s_scratch_slot t_scratch_slot
 Represents a single slot in the scratch arena pool.
 

Functions

static bool scratch_slot_init (t_scratch_slot *slot, size_t slot_size, int index)
 Initialize a single scratch slot with its own arena.
 

Detailed Description

Internal helpers and utilities for scratch arena pool management.


Data Structure Documentation

◆ s_scratch_slot

struct s_scratch_slot

Represents a single slot in the scratch arena pool.

Each slot holds a memory arena (t_arena) and an atomic flag indicating whether the slot is currently in use.

Examples
/home/toonsa/myProjects/memoryArena/srcs/core/arena_scratch.c.

Definition at line 73 of file arena_scratch.h.

+ Collaboration diagram for s_scratch_slot:
Data Fields
t_arena arena Memory arena associated with this slot.
atomic_bool in_use Atomic flag for acquisition tracking.

Typedef Documentation

◆ t_scratch_slot

#include <arena_scratch.h>

Represents a single slot in the scratch arena pool.

Each slot holds a memory arena (t_arena) and an atomic flag indicating whether the slot is currently in use.

Function Documentation

◆ scratch_slot_init()

static bool scratch_slot_init ( t_scratch_slot *  slot,
size_t  slot_size,
int  index 
)
static

#include <arena_scratch.c>

Initialize a single scratch slot with its own arena.

This internal helper sets up a t_scratch_slot by initializing the internal arena with the given slot_size. The arena is marked as growable, and the slot is initially marked as not in use.

On failure, an error is reported using arena_report_error(), indicating the index of the slot that failed to initialize.

Parameters
slotPointer to the scratch slot to initialize.
slot_sizeSize of the arena to allocate for the slot.
indexIndex of the slot (used for debugging/logging).
Returns
true if the slot was successfully initialized, false otherwise.
Note
This function is called during scratch_pool_init() to initialize each slot in the scratch pool.
See also
scratch_pool_init
arena_init
Examples
/home/toonsa/myProjects/memoryArena/srcs/core/arena_scratch.c.

Definition at line 449 of file arena_scratch.c.

450{
451 if (!arena_init(&slot->arena, slot_size, true))
452 {
453 arena_report_error(NULL, "scratch_slot_init failed: arena_init failed for slot %d", index);
454 return false;
455 }
456 atomic_store(&slot->in_use, false);
457 return true;
458}
bool arena_init(t_arena *arena, size_t size, bool allow_grow)
void arena_report_error(t_arena *arena, const char *fmt,...)
Report an error from an arena using its configured error callback.
atomic_bool in_use
Atomic flag for acquisition tracking.
t_arena arena
Memory arena associated with this slot.

References s_scratch_slot::arena, arena_init(), arena_report_error(), and s_scratch_slot::in_use.