87 bool expected =
false;
88 if (!atomic_compare_exchange_strong(&arena->is_destroying, &expected,
true))
91#ifdef ARENA_ENABLE_THREAD_SAFE
103 arena->use_lock =
false;
104 pthread_mutex_destroy(&arena->lock);
150 if (!arena || !*arena)
188 bool owns = atomic_load_explicit(&arena->owns_buffer, memory_order_acquire);
189 if (owns && arena->buffer)
193 arena->buffer = NULL;
194 atomic_store_explicit(&arena->owns_buffer,
false, memory_order_release);
223 if (arena->stats.growth_history)
225 arena_poison_memory(arena->stats.growth_history,
sizeof(
size_t) * arena->stats.growth_history_count);
226 free(arena->stats.growth_history);
227 arena->stats.growth_history = NULL;
Core public API for the Arena memory allocator.
void arena_destroy(t_arena *arena)
void arena_delete(t_arena **arena)
#define arena_poison_memory(ptr, size)
No-op poison macro when poisoning is disabled.
#define ARENA_CHECK(arena)
#define ARENA_UNLOCK(arena)
#define ARENA_LOCK(arena)
Acquire the mutex lock if thread safety is enabled.
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.
void arena_zero_metadata(t_arena *arena)
Zero out and reset all debug/stats metadata associated with the arena.
The main memory arena structure used for fast allocation.