Originally posted by houssemeddine-mbarek August 27, 2026
Add support for customizing the memory allocation functions used by the library.
Currently, memory allocations rely on the default calloc()/free() implementation and therefore use the default heap. The requested enhancement is to allow users to provide their own allocation and deallocation functions.
For example, the library should provide a mechanism to configure:
- A custom calloc() implementation
- A custom free() implementation
This would allow applications to redirect dynamic allocations to a specific memory region or custom memory manager instead of the default heap.
Example use case:
void *custom_calloc(size_t size);
void custom_free(void *ptr);
library_set_memory_functions(custom_calloc, custom_free);
This is particularly useful for embedded systems where different memory regions may have different properties or may be dedicated to specific purposes (e.g. internal SRAM, external RAM, DMA-accessible RAM, etc.).
The default behavior should remain unchanged when no custom allocator is provided.
Discussed in https://github.com/orgs/osdp-dev/discussions/330
Originally posted by houssemeddine-mbarek August 27, 2026
Add support for customizing the memory allocation functions used by the library.
Currently, memory allocations rely on the default calloc()/free() implementation and therefore use the default heap. The requested enhancement is to allow users to provide their own allocation and deallocation functions.
For example, the library should provide a mechanism to configure:
This would allow applications to redirect dynamic allocations to a specific memory region or custom memory manager instead of the default heap.
Example use case:
void *custom_calloc(size_t size);
void custom_free(void *ptr);
library_set_memory_functions(custom_calloc, custom_free);
This is particularly useful for embedded systems where different memory regions may have different properties or may be dedicated to specific purposes (e.g. internal SRAM, external RAM, DMA-accessible RAM, etc.).
The default behavior should remain unchanged when no custom allocator is provided.