Skip to content

Commit 3327ffa

Browse files
babboysBernardXiong
authored andcommitted
[update] 使用memheap内存管理时,rt_malloc 0长度返回RT_NULL, 与slab与小内存管理等算法保持一致。
1 parent 7455e24 commit 3327ffa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/memheap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,10 @@ void *rt_malloc(rt_size_t size)
850850
{
851851
void *ptr;
852852

853+
/* zero size, return RT_NULL */
854+
if (size == 0)
855+
return RT_NULL;
856+
853857
/* try to allocate in system heap */
854858
ptr = rt_memheap_alloc(&_heap, size);
855859
#ifdef RT_USING_MEMHEAP_AUTO_BINDING

0 commit comments

Comments
 (0)