|
memory_arena
|
Public functions for memory allocation from an arena. More...
Files | |
| file | arena_alloc.c |
| Public memory allocation functions for the arena allocator. | |
| file | arena_calloc.c |
| Zero-initialized memory allocation functions for arenas. | |
| file | arena_hooks.c |
| Allocation hook management for tracking and debugging arena memory usage. | |
| file | arena_hooks.h |
| Allocation hook system for arena-based memory tracking and introspection. | |
Functions | |
| void | arena_set_allocation_hook (t_arena *arena, arena_allocation_hook cb, void *context) |
| Set or remove an allocation hook on a given arena. | |
Public functions for memory allocation from an arena.
| void arena_set_allocation_hook | ( | t_arena * | arena, |
| arena_allocation_hook | cb, | ||
| void * | context | ||
| ) |
#include <arena_hooks.h>
Set or remove an allocation hook on a given arena.
Set a custom allocation hook for the given arena.
This function installs a callback that will be invoked after each successful allocation (including realloc and calloc) within the specified arena.
If cb is NULL, any previously installed hook is removed.
| arena | Pointer to the target arena. |
| cb | Hook callback function (or NULL to disable). |
| context | Optional user-defined context passed to the hook. |
This function installs a user-defined allocation hook on the specified arena. The hook is a callback function that will be invoked after each successful memory allocation (arena_alloc, arena_calloc, arena_realloc_last), allowing custom instrumentation, logging, debugging, or tracking.
The hook receives detailed metadata for each allocation, including:
NULL).If cb is NULL, the current hook will be removed and no further allocation events will be triggered.
| arena | Pointer to the arena to attach the hook to. |
| cb | Hook callback function, or NULL to disable. |
| context | Optional user data or context to associate with the hook (not used internally). |
arena_alloc_internal() implementation. If thread safety is enabled, this function acquires the arena lock to modify internal state.Definition at line 163 of file arena_hooks.c.
References ARENA_LOCK, arena_report_error(), and ARENA_UNLOCK.