elpekenin/utils/allocator.h
¶
Utilities to use custom allocators instead of stdlib’s implementation.
This is: malloc()
, free()
, calloc()
and realloc()
.
-
struct allocator_t¶
[source] Information about a custom allocator.
-
realloc_fn realloc¶
[source] Pointer to its
realloc
implementation.
-
realloc_fn realloc¶
Caution
These wrappers add some extra logic as well as calling allocator->function(args)
.
Use them instead of manually executing the functions.
-
void *malloc_with(allocator_t *allocator, size_t total_size)¶
[source] Run
malloc
’s implementation of the given allocator.
-
void free_with(allocator_t *allocator, void *ptr)¶
[source] Run
free
’s implementation of the given allocator.
-
void *calloc_with(allocator_t *allocator, size_t nmemb, size_t size)¶
[source] Run
calloc
’s implementation of the given allocator.
-
void *realloc_with(allocator_t *allocator, void *ptr, size_t size)¶
[source] Run
realloc
’s implementation of the given allocator.
-
const allocator_t **get_known_allocators(int8_t *n)¶
[source] Get a pointer to every allocator implementation.
n
will be set to the number of allocators.
-
allocator_t *get_default_allocator(void)¶
[source] Get the allocator defined as “default”.
-
extern allocator_t c_runtime_allocator¶
[source] C’s stdlib allocator.
-
extern allocator_t ch_core_allocator¶
[source] ChibiOS’ core allocator.
-
allocator_t new_ch_pool_allocator(memory_pool_t *pool, const char *name)¶
[source] Create a new ChibiOS’ pool allocator.
-
allocator_t new_ch_heap_allocator(memory_heap_t *heap, const char *name)¶
[source] Create a new ChibiOS’ heap allocator.