diff --git a/inc/stdlib.h b/inc/stdlib.h index 5549f73..c6d981d 100644 --- a/inc/stdlib.h +++ b/inc/stdlib.h @@ -16,27 +16,12 @@ #endif -#ifdef _RTLIBC_MALLOC_ - void malloc_init(void *heap, size_t size, size_t alignment); size_t msize(void *p); void* malloc(size_t size); void free(void *p); -#endif - -#ifdef _RTLIBC_MALLOC_FREERTOS_ - -#define malloc_init() -#define msize() (0) - -#define malloc(size) pvPortMalloc(size) -#define free(ptr) vPortFree(ptr) - -#endif - - uint64_t strtoul(const char *str, char **endptr, int32_t base); int64_t strtol(const char *str, char **endptr, int32_t base); diff --git a/src/stdlib.c b/src/stdlib.c index 32f5e1f..2fb9b5c 100644 --- a/src/stdlib.c +++ b/src/stdlib.c @@ -281,12 +281,10 @@ } - -#ifdef _RTLIBC_MALLOC_ - static rtmalloc_context_t l_malloc_context; -__attribute__((weak)) void rtlibc_malloc_failed_handler(void) +__attribute__((weak)) +void rtlibc_malloc_failed_handler(void) { } @@ -298,6 +296,7 @@ rtmalloc_init(&l_malloc_context, heap, size, alignment); } +__attribute__ ((weak)) void* malloc(size_t size) { void *ptr = rtmalloc(&l_malloc_context, size); @@ -308,6 +307,7 @@ return ptr; } +__attribute__ ((weak)) void free(void *p) { assert(p); @@ -319,5 +319,3 @@ assert(p); return rtmsize(&l_malloc_context, p); } - -#endif