memory_arena
Loading...
Searching...
No Matches
arena_hooks.c
Go to the documentation of this file.
1
121#include "arena.h"
122
164{
165 if (!arena)
166 {
167 arena_report_error(NULL, "arena_set_allocation_hook failed: NULL arena");
168 return;
169 }
170
171 ARENA_LOCK(arena);
172 arena->hooks.hook_cb = cb;
173 arena->hooks.context = context;
174 ARENA_UNLOCK(arena);
175}
Core public API for the Arena memory allocator.
void(* arena_allocation_hook)(t_arena *arena, int alloc_id, void *ptr, size_t size, size_t offset, size_t wasted, const char *label)
Allocation hook callback type.
Definition arena_hooks.h:58
#define ARENA_UNLOCK(arena)
#define ARENA_LOCK(arena)
Acquire the mutex lock if thread safety is enabled.
void arena_set_allocation_hook(t_arena *arena, arena_allocation_hook cb, void *context)
Set or remove an allocation hook on a given arena.
void arena_report_error(t_arena *arena, const char *fmt,...)
Report an error from an arena using its configured error callback.
The main memory arena structure used for fast allocation.