116#if ARENA_ENABLE_THREAD_LOCAL_SCRATCH
144_Thread_local
static t_arena thread_scratch_arena;
145_Thread_local
static bool thread_scratch_initialized =
false;
146_Thread_local
static size_t thread_scratch_size = 8192;
178 if (!thread_scratch_initialized)
179 thread_scratch_size = size;
212 return &thread_scratch_arena;
246 if (!thread_scratch_initialized)
248 arena_init(&thread_scratch_arena, 8192,
true);
249 thread_scratch_initialized =
true;
252 return &thread_scratch_arena;
280 if (thread_scratch_initialized)
283 thread_scratch_initialized =
false;
291 arena_report_error(NULL,
"get_thread_scratch_arena() called but ARENA_ENABLE_THREAD_LOCAL_SCRATCH is disabled");
297 arena_report_error(NULL,
"destroy_thread_scratch_arena() called but ARENA_ENABLE_THREAD_LOCAL_SCRATCH is disabled");
303 arena_report_error(NULL,
"set_thread_scratch_arena_size() called but ARENA_ENABLE_THREAD_LOCAL_SCRATCH is "
309 arena_report_error(NULL,
"get_thread_scratch_arena_ref() called but ARENA_ENABLE_THREAD_LOCAL_SCRATCH is disabled");
Core public API for the Arena memory allocator.
void arena_reset(t_arena *arena)
bool arena_init(t_arena *arena, size_t size, bool allow_grow)
void arena_destroy(t_arena *arena)
void arena_report_error(t_arena *arena, const char *fmt,...)
Report an error from an arena using its configured error callback.
void destroy_thread_scratch_arena(void)
Destroy the thread-local scratch arena for the calling thread.
t_arena * get_thread_scratch_arena(void)
Get the thread-local scratch arena, resetting it before use.
t_arena * get_thread_scratch_arena_ref(void)
Access the raw thread-local arena pointer without initialization.
void set_thread_scratch_arena_size(size_t size)
Configure the initial size for the thread-local scratch arena.
The main memory arena structure used for fast allocation.