7#ifndef ZEPHYR_INCLUDE_SYS_HEAP_LISTENER_H
8#define ZEPHYR_INCLUDE_SYS_HEAP_LISTENER_H
18#if defined(CONFIG_HEAP_LISTENER) || defined(__DOXYGEN__)
72 void *mem,
size_t bytes);
91 void *mem,
size_t bytes);
182#define HEAP_ID_FROM_POINTER(heap_pointer) ((uintptr_t)heap_pointer)
189#define HEAP_ID_LIBC ((uintptr_t)0)
208#define HEAP_LISTENER_ALLOC_DEFINE(name, _heap_id, _alloc_cb) \
209 struct heap_listener name = { \
210 .heap_id = _heap_id, \
211 .event = HEAP_ALLOC, \
213 .alloc_cb = _alloc_cb \
234#define HEAP_LISTENER_FREE_DEFINE(name, _heap_id, _free_cb) \
235 struct heap_listener name = { \
236 .heap_id = _heap_id, \
237 .event = HEAP_FREE, \
239 .free_cb = _free_cb \
260#define HEAP_LISTENER_RESIZE_DEFINE(name, _heap_id, _resize_cb) \
261 struct heap_listener name = { \
262 .heap_id = _heap_id, \
263 .event = HEAP_RESIZE, \
265 .resize_cb = _resize_cb \
273#define HEAP_ID_FROM_POINTER(heap_pointer) ((uintptr_t)NULL)
293 ARG_UNUSED(old_heap_end);
294 ARG_UNUSED(new_heap_end);
void(* heap_listener_resize_cb_t)(uintptr_t heap_id, void *old_heap_end, void *new_heap_end)
Callback used when heap is resized.
Definition: heap_listener.h:51
void heap_listener_register(struct heap_listener *listener)
Register heap event listener.
void heap_listener_unregister(struct heap_listener *listener)
Unregister heap event listener.
void heap_listener_notify_free(uintptr_t heap_id, void *mem, size_t bytes)
Notify listeners of heap free event.
heap_event_types
Definition: heap_listener.h:26
void(* heap_listener_alloc_cb_t)(uintptr_t heap_id, void *mem, size_t bytes)
Callback used when there is heap allocation.
Definition: heap_listener.h:71
void heap_listener_notify_resize(uintptr_t heap_id, void *old_heap_end, void *new_heap_end)
Notify listeners of heap resize event.
void(* heap_listener_free_cb_t)(uintptr_t heap_id, void *mem, size_t bytes)
Callback used when memory is freed from heap.
Definition: heap_listener.h:90
void heap_listener_notify_alloc(uintptr_t heap_id, void *mem, size_t bytes)
Notify listeners of heap allocation event.
@ HEAP_RESIZE
Definition: heap_listener.h:33
@ HEAP_ALLOC
Definition: heap_listener.h:34
@ HEAP_FREE
Definition: heap_listener.h:35
@ HEAP_REALLOC
Definition: heap_listener.h:36
@ HEAP_EVT_UNKNOWN
Definition: heap_listener.h:31
@ HEAP_MAX_EVENTS
Definition: heap_listener.h:38
struct _snode sys_snode_t
Single-linked list node structure.
Definition: slist.h:39
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:105
Definition: heap_listener.h:93
heap_listener_resize_cb_t resize_cb
Definition: heap_listener.h:113
enum heap_event_types event
The heap event to be notified.
Definition: heap_listener.h:108
heap_listener_alloc_cb_t alloc_cb
Definition: heap_listener.h:111
heap_listener_free_cb_t free_cb
Definition: heap_listener.h:112
uintptr_t heap_id
Identifier of the heap whose events are listened.
Definition: heap_listener.h:103
sys_snode_t node
Singly linked list node.
Definition: heap_listener.h:95