memory_arena
Loading...
Searching...
No Matches
arena_hooks.h
Go to the documentation of this file.
1
32#ifndef ARENA_HOOKS_H
33#define ARENA_HOOKS_H
34
35#include <stdatomic.h>
36
37#ifdef __cplusplus
38extern "C"
39{
40#endif
41
45 typedef struct s_arena t_arena;
46
58 typedef void (*arena_allocation_hook)(t_arena* arena, int alloc_id, void* ptr, size_t size, size_t offset,
59 size_t wasted, const char* label);
60
72
97 void arena_set_allocation_hook(t_arena* arena, arena_allocation_hook cb, void* context);
98
99#ifdef __cplusplus
100}
101#endif
102
103#endif // ARENA_HOOKS_H
size_t size
Total size of the buffer.
Definition arena.h:131
size_t offset
Current used offset (bump pointer).
Definition arena.h:132
struct s_arena_hooks t_arena_hooks
Internal structure for managing arena hooks.
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
void arena_set_allocation_hook(t_arena *arena, arena_allocation_hook cb, void *context)
Set or remove an allocation hook on a given arena.
The main memory arena structure used for fast allocation.
Internal structure for managing arena hooks.
Definition arena_hooks.h:68
_Atomic(arena_allocation_hook) hook_cb
The active allocation hook callback.
void * context
Optional user data passed to the hook.
Definition arena_hooks.h:70