arch/sim: do not free memory of zero-length reallocation
Follow the change: https://github.com/apache/nuttx/pull/9151, if MM_CUSTOMIZE_MANAGER is enabled, heap memory manager in host is used, for example in sim:asan build. malloc and related allocation APIs will fall back to host_realloc, do not free memory of zero-length reallocation. So memory allocations return valid pointer when request zero size in all sim build. call stack: malloc() (mm/umm_heap/umm_malloc.c) mm_malloc() (arch/sim/src/sim/sim_heap.c) mm_realloc() (arch/sim/src/sim/sim_heap.c) host_realloc() (arch/sim/src/sim/posix/sim_hostmemory.c) host_memalign() (arch/sim/src/sim/posix/sim_hostmemory.c) Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
This commit is contained in:
parent
73257eeda0
commit
06f8875c0c
@ -217,12 +217,7 @@ void *host_realloc(void *oldmem, size_t size)
|
||||
size_t oldsize;
|
||||
void *mem;
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
host_free(oldmem);
|
||||
return NULL;
|
||||
}
|
||||
else if (oldmem == NULL)
|
||||
if (oldmem == NULL)
|
||||
{
|
||||
return host_memalign(sizeof(void *), size);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user