[feat][bsp_common/platform] complete calloc function that float print needs

This commit is contained in:
jzlv 2021-10-19 20:06:47 +08:00
parent 626c6f3fae
commit 31564a9bdd

View file

@ -232,14 +232,19 @@ void *_realloc_r(struct _reent *ptr, void *old, size_t newlen)
if (result == NULL) { if (result == NULL) {
ptr->_errno = -ENOMEM; ptr->_errno = -ENOMEM;
} }
return result; return result;
} }
void *_calloc_r(struct _reent *ptr, size_t size, size_t len) void *_calloc_r(struct _reent *ptr, size_t size, size_t len)
{ {
/* return "not supported" */ void *result;
return 0;
result = (void *)mmheap_calloc(&mmheap_root, size, len);
if (result == NULL) {
ptr->_errno = -ENOMEM;
}
return result;
} }
void _free_r(struct _reent *ptr, void *addr) void _free_r(struct _reent *ptr, void *addr)
@ -249,7 +254,11 @@ void _free_r(struct _reent *ptr, void *addr)
void *_sbrk_r(struct _reent *ptr, ptrdiff_t incr) void *_sbrk_r(struct _reent *ptr, ptrdiff_t incr)
{ {
return 0; void *ret;
ptr->_errno = ENOMEM;
ret = (void *)-1;
return ret;
} }
/* for exit() and abort() */ /* for exit() and abort() */