Feature Request: Customizable Memory Allocation #330
houssemeddine-mbarek
started this conversation in
Ideas
Replies: 1 comment 1 reply
|
I can provide weak symbols osdp_calloc() and osdp_free() which defaults to calloc() and fee() when a stronger symbol is not provided. Is that sufficient? A custom library_set_memory_functions an API surface plus a pointer indirection which I would prefer to avoid. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
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.
All reactions