mm: Support malloc_size function

and rename malloc_usable_size to malloc_size

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I8d83e9148d70e752142af26d7dd9a291123fdd14
This commit is contained in:
Xiang Xiao
2021-06-27 03:57:56 +08:00
parent 29d1bc9e87
commit 4e3c1ed8af
5 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -3645,7 +3645,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);
+3 -1
View File
@@ -31,6 +31,8 @@
* Pre-processor Definitions
****************************************************************************/
#define malloc_usable_size malloc_size
/****************************************************************************
* Public Type Definitions
****************************************************************************/
@@ -58,7 +60,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)
}
+3 -3
View File
@@ -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
@@ -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;
+2 -2
View File
@@ -855,10 +855,10 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
}
/****************************************************************************
* Name: malloc_usable_size
* Name: malloc_size
****************************************************************************/
size_t malloc_usable_size(FAR void *mem)
size_t malloc_size(FAR void *mem)
{
return tlsf_block_size(mem);
}