aboutsummaryrefslogtreecommitdiffstats
path: root/src/stdlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib.c')
-rw-r--r--src/stdlib.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/stdlib.c b/src/stdlib.c
index 3ad66b37..21b506a8 100644
--- a/src/stdlib.c
+++ b/src/stdlib.c
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <string.h>
#include <FreeRTOS.h>
// Override malloc() and free() to use the memory manager from FreeRTOS.
@@ -10,18 +11,41 @@ void* malloc(size_t size) {
return pvPortMalloc(size);
}
+void* __wrap_malloc(size_t size) {
+ return malloc(size);
+}
+
+void* __wrap__malloc_r(struct _reent* reent, size_t size) {
+ (void) reent;
+ return malloc(size);
+}
+
void free(void* ptr) {
vPortFree(ptr);
}
+void __wrap_free(void* ptr) {
+ free(ptr);
+}
+
void* calloc(size_t num, size_t size) {
- (void)(num);
- (void)(size);
- // Not supported
- return NULL;
+ void *ptr = malloc(num * size);
+ if (ptr) {
+ memset(ptr, 0, num * size);
+ }
+ return ptr;
}
-void *pvPortRealloc(void *ptr, size_t xWantedSize);
-void* realloc( void *ptr, size_t newSize) {
+void* __wrap_calloc(size_t num, size_t size) {
+ return calloc(num, size);
+}
+
+void* pvPortRealloc(void* ptr, size_t xWantedSize);
+
+void* realloc(void* ptr, size_t newSize) {
return pvPortRealloc(ptr, newSize);
}
+
+void* __wrap_realloc(void* ptr, size_t newSize) {
+ return realloc(ptr, newSize);
+}