This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 97216c220be4ca3c7518228c502b5def868d79ce Author: Xiang Xiao <xiaoxi...@xiaomi.com> AuthorDate: Sun Jun 27 03:57:56 2021 +0800 mm: Support malloc_size function and rename malloc_usable_size to malloc_size Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com> --- arch/xtensa/src/esp32/esp32_wifi_adapter.c | 2 +- include/malloc.h | 6 +++++- mm/mm_heap/Make.defs | 6 +++--- mm/mm_heap/{mm_malloc_usable_size.c => mm_malloc_size.c} | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/xtensa/src/esp32/esp32_wifi_adapter.c b/arch/xtensa/src/esp32/esp32_wifi_adapter.c index fe79707..87e5819 100644 --- a/arch/xtensa/src/esp32/esp32_wifi_adapter.c +++ b/arch/xtensa/src/esp32/esp32_wifi_adapter.c @@ -3674,7 +3674,7 @@ static void *esp_realloc_internal(void *ptr, size_t size) return NULL; } - old_size = malloc_usable_size(old_ptr); + old_size = malloc_size(old_ptr); DEBUGASSERT(old_size > 0); memcpy(new_ptr, old_ptr, MIN(old_size, size)); kmm_free(old_ptr); diff --git a/include/malloc.h b/include/malloc.h index a4bc6c4..0854174 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -31,6 +31,10 @@ * Pre-processor Definitions ****************************************************************************/ +/* For Linux and MacOS compatibility */ + +#define malloc_usable_size malloc_size + /**************************************************************************** * Public Type Definitions ****************************************************************************/ @@ -58,7 +62,7 @@ extern "C" #endif struct mallinfo mallinfo(void); -size_t malloc_usable_size(FAR void *ptr); +size_t malloc_size(FAR void *ptr); #if defined(__cplusplus) } diff --git a/mm/mm_heap/Make.defs b/mm/mm_heap/Make.defs index b44f988..678c52c 100644 --- a/mm/mm_heap/Make.defs +++ b/mm/mm_heap/Make.defs @@ -23,9 +23,9 @@ ifeq ($(CONFIG_MM_DEFAULT_MANAGER),y) CSRCS += mm_initialize.c mm_sem.c mm_addfreechunk.c mm_size2ndx.c -CSRCS += mm_malloc_usable_size.c mm_shrinkchunk.c -CSRCS += mm_brkaddr.c mm_calloc.c mm_extend.c mm_free.c mm_mallinfo.c -CSRCS += mm_malloc.c mm_memalign.c mm_realloc.c mm_zalloc.c mm_heapmember.c +CSRCS += mm_malloc_size.c mm_shrinkchunk.c mm_brkaddr.c mm_calloc.c +CSRCS += mm_extend.c mm_free.c mm_mallinfo.c mm_malloc.c +CSRCS += mm_memalign.c mm_realloc.c mm_zalloc.c mm_heapmember.c ifeq ($(CONFIG_BUILD_KERNEL),y) CSRCS += mm_sbrk.c diff --git a/mm/mm_heap/mm_malloc_usable_size.c b/mm/mm_heap/mm_malloc_size.c similarity index 95% rename from mm/mm_heap/mm_malloc_usable_size.c rename to mm/mm_heap/mm_malloc_size.c index b4df717..40bc7b2 100644 --- a/mm/mm_heap/mm_malloc_usable_size.c +++ b/mm/mm_heap/mm_malloc_size.c @@ -1,5 +1,5 @@ /**************************************************************************** - * mm/mm_heap/mm_malloc_usable_size.c + * mm/mm_heap/mm_malloc_size.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -36,7 +36,7 @@ * Public Functions ****************************************************************************/ -size_t malloc_usable_size(FAR void *mem) +size_t malloc_size(FAR void *mem) { FAR struct mm_freenode_s *node;