Hint

Refer to QMK’s documentation for details on how to use community modules

allocator

Utilities to use custom allocators instead of stdlib’s implementation.

This is: malloc(), free(), calloc() and realloc().

struct lifetime_t
[source]

Information about an object’s lifetime.

uint32_t start
[source]

When was the memory allocated.

uint32_t end
[source]

When was the memory freed.

struct alloc_stats_t
[source]

Information about an allocation.

const allocator_t *allocator
[source]

Allocator used to request this memory.

void *ptr
[source]

Pointer to the memory region provided by allocator.

size_t size
[source]

Size in bytes of the memory region.

lifetime_t lifetime
[source]

Allocation’s duration.

type malloc_fn
[source]

Signature of a malloc() function.

type free_fn
[source]

Signature of a free() function.

type calloc_fn
[source]

Signature of a calloc() function.

type realloc_fn
[source]

Signature of a realloc() function.

struct allocator_t
[source]

Information about a custom allocator.

const malloc_fn malloc
[source]

Pointer to its malloc implementation.

const free_fn free
[source]

Pointer to its free implementation.

const calloc_fn calloc
[source]

Pointer to its calloc implementation.

const realloc_fn realloc
[source]

Pointer to its realloc implementation.

const char *const name
[source]

A short name/description.

void *arg
[source]

F Arbitrary config used by allocator. Eg a ChibiOS’ pool.

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(const allocator_t *allocator, size_t total_size)
[source]

Run malloc’s implementation of the given allocator.

void free_with(const allocator_t *allocator, void *ptr)
[source]

Run free’s implementation of the given allocator.

void *calloc_with(const allocator_t *allocator, size_t nmemb, size_t size)
[source]

Run calloc’s implementation of the given allocator.

void *realloc_with(const allocator_t *allocator, void *ptr, size_t size)
[source]

Run realloc’s implementation of the given allocator.

size_t get_used_heap(void)
[source]

Total heap used between all allocators.

const allocator_t *const *get_known_allocators(size_t *n)
[source]

Get a pointer to every allocator implementation.

n will be set to the number of allocators.

const alloc_stats_t *get_allocations(size_t *n)
[source]

Get a pointer to every tracked allocation implementation.

n will be set to the number of allocation.

extern const allocator_t *const ch_core_allocator
[source]

ChibiOS’ core allocator.

const allocator_t new_ch_pool_allocator(int *pool, const char *name)
[source]

Create a new ChibiOS’ pool allocator.

const allocator_t new_ch_heap_allocator(int *heap, const char *name)
[source]

Create a new ChibiOS’ heap allocator.