|
memory_arena
|
Allocation hook system for arena-based memory tracking and introspection. More...
#include <stdatomic.h>
Include dependency graph for arena_hooks.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | s_arena_hooks |
| Internal structure for managing arena hooks. More... | |
Typedefs | |
| typedef 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. | |
| typedef struct s_arena | t_arena |
| Forward declaration of arena structure. | |
| typedef struct s_arena_hooks | t_arena_hooks |
| Internal structure for managing arena hooks. | |
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. | |
Allocation hook system for arena-based memory tracking and introspection.
This module allows users to attach custom callback functions (hooks) to arena allocators. These hooks are triggered after each successful allocation, providing detailed metadata for logging, profiling, or visualization tools.
Features:
Typical use cases:
Definition in file arena_hooks.h.
| typedef 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.
| arena | The arena from which memory was allocated. |
| alloc_id | A unique ID for this allocation (monotonic counter). |
| ptr | Pointer to the newly allocated memory. |
| size | Size of the allocation in bytes. |
| offset | Offset from the start of the arena buffer. |
| wasted | Number of bytes wasted for alignment. |
| label | Optional label associated with the allocation. |
Definition at line 58 of file arena_hooks.h.
Forward declaration of arena structure.
Definition at line 45 of file arena_hooks.h.
| typedef struct s_arena_hooks t_arena_hooks |
Internal structure for managing arena hooks.
This structure stores the current allocation hook and an optional user-defined context that can be used inside the hook.