2021-02-23 03:21:16 +08:00
|
|
|
/*
|
2021-03-08 18:19:04 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2021-02-23 03:21:16 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2021-02-23 Meco Man first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <reent.h>
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
2021-02-28 11:09:48 +08:00
|
|
|
#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)
|
2021-02-23 03:21:16 +08:00
|
|
|
{
|
|
|
|
return RT_NULL;
|
|
|
|
}
|
2021-02-28 11:09:48 +08:00
|
|
|
#endif /*RT_USING_HEAP*/
|