diff options
Diffstat (limited to 'src/stdlib.c')
| -rw-r--r-- | src/stdlib.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/stdlib.c b/src/stdlib.c new file mode 100644 index 00000000..3ad66b37 --- /dev/null +++ b/src/stdlib.c @@ -0,0 +1,27 @@ +#include <stdlib.h> +#include <FreeRTOS.h> + +// Override malloc() and free() to use the memory manager from FreeRTOS. +// According to the documentation of libc, we also need to override +// calloc and realloc. +// See https://www.gnu.org/software/libc/manual/html_node/Replacing-malloc.html + +void* malloc(size_t size) { + return pvPortMalloc(size); +} + +void free(void* ptr) { + vPortFree(ptr); +} + +void* calloc(size_t num, size_t size) { + (void)(num); + (void)(size); + // Not supported + return NULL; +} + +void *pvPortRealloc(void *ptr, size_t xWantedSize); +void* realloc( void *ptr, size_t newSize) { + return pvPortRealloc(ptr, newSize); +} |
