summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzhouji <[email protected]>2021-12-12 11:16:26 +0800
committerBernard Xiong <[email protected]>2021-12-14 06:16:59 +0800
commit3327ffaa155b646d1ce04755388d1e0f8a522caa (patch)
tree9b2e8538bd9fe1b64368cb325cb8a4221e2a0c81 /src
parent7455e2487bd420c06ba7198228b0dcca297f83cc (diff)
[update] 使用memheap内存管理时,rt_malloc 0长度返回RT_NULL, 与slab与小内存管理等算法保持一致。
Diffstat (limited to 'src')
-rw-r--r--src/memheap.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/memheap.c b/src/memheap.c
index 68a15d1a8e..9c3f570f29 100644
--- a/src/memheap.c
+++ b/src/memheap.c
@@ -850,6 +850,10 @@ void *rt_malloc(rt_size_t size)
{
void *ptr;
+ /* zero size, return RT_NULL */
+ if (size == 0)
+ return RT_NULL;
+
/* try to allocate in system heap */
ptr = rt_memheap_alloc(&_heap, size);
#ifdef RT_USING_MEMHEAP_AUTO_BINDING