diff options
| author | Meco Man <[email protected]> | 2021-02-28 11:09:48 +0800 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2021-02-28 11:09:48 +0800 |
| commit | ac275965f2e2d3ff730d06a8962ccaaea4f027ce (patch) | |
| tree | aada14e3a4ecffd74d672bf5ebe3b6a05dc7c607 /components/libc/compilers/newlib/minilib.c | |
| parent | 8932ffdb96b793031bbc71bb3bd23202939fcb2c (diff) | |
[libc][newlib] 对syscall中malloc相关桩函数做出编译调整
Diffstat (limited to 'components/libc/compilers/newlib/minilib.c')
| -rw-r--r-- | components/libc/compilers/newlib/minilib.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/components/libc/compilers/newlib/minilib.c b/components/libc/compilers/newlib/minilib.c index 2d07eabe5a..92877bd6c3 100644 --- a/components/libc/compilers/newlib/minilib.c +++ b/components/libc/compilers/newlib/minilib.c @@ -11,8 +11,59 @@ #include <reent.h> #include <rtthread.h> -void * _sbrk_r(struct _reent *ptr, ptrdiff_t incr) +#ifdef RT_USING_HEAP /* Memory routine */ +void * +_malloc_r (struct _reent *ptr, size_t size) +{ + void* result; + + result = (void*)rt_malloc (size); + if (result == RT_NULL) + { + ptr->_errno = ENOMEM; + } + + return result; +} + +void * +_realloc_r (struct _reent *ptr, void *old, size_t newlen) +{ + void* result; + + result = (void*)rt_realloc (old, newlen); + if (result == RT_NULL) + { + ptr->_errno = ENOMEM; + } + + return result; +} + +void *_calloc_r (struct _reent *ptr, size_t size, size_t len) +{ + void* result; + + result = (void*)rt_calloc (size, len); + if (result == RT_NULL) + { + ptr->_errno = ENOMEM; + } + + return result; +} + +void +_free_r (struct _reent *ptr, void *addr) +{ + rt_free (addr); +} + +#else +void * +_sbrk_r(struct _reent *ptr, ptrdiff_t incr) { /* no use this routine to get memory */ return RT_NULL; } +#endif /*RT_USING_HEAP*/ |
