mm: Add kmm_malloc_size and mm_malloc_size

make malloc_size implementation align with malloc

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I8d7781925f06e58a880437a16569dccbfd2ea035
This commit is contained in:
Xiang Xiao
2021-06-30 20:33:29 -07:00
committed by Masayuki Ishikawa
parent ddaa3e42b9
commit 75bfa4584c
9 changed files with 118 additions and 25 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
ifeq ($(CONFIG_MM_KERNEL_HEAP),y)
CSRCS += kmm_initialize.c kmm_addregion.c
CSRCS += kmm_initialize.c kmm_addregion.c kmm_malloc_size.c
CSRCS += kmm_brkaddr.c kmm_calloc.c kmm_extend.c kmm_free.c kmm_mallinfo.c
CSRCS += kmm_malloc.c kmm_memalign.c kmm_realloc.c kmm_zalloc.c kmm_heapmember.c
+40
View File
@@ -0,0 +1,40 @@
/****************************************************************************
* mm/kmm_heap/kmm_malloc_size.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/mm/mm.h>
#ifdef CONFIG_MM_KERNEL_HEAP
/****************************************************************************
* Public Functions
****************************************************************************/
size_t kmm_malloc_size(FAR void *mem)
{
return mm_malloc_size(mem);
}
#endif /* CONFIG_MM_KERNEL_HEAP */
+1 -2
View File
@@ -26,7 +26,6 @@
#include <assert.h>
#include <debug.h>
#include <malloc.h>
#include <nuttx/mm/mm.h>
@@ -36,7 +35,7 @@
* Public Functions
****************************************************************************/
size_t malloc_size(FAR void *mem)
size_t mm_malloc_size(FAR void *mem)
{
FAR struct mm_freenode_s *node;
+1 -1
View File
@@ -20,7 +20,7 @@
# User heap allocator
CSRCS += umm_globals.c umm_initialize.c umm_addregion.c
CSRCS += umm_globals.c umm_initialize.c umm_addregion.c umm_malloc_size.c
CSRCS += umm_brkaddr.c umm_calloc.c umm_extend.c umm_free.c umm_mallinfo.c
CSRCS += umm_malloc.c umm_memalign.c umm_realloc.c umm_zalloc.c umm_heapmember.c
+38
View File
@@ -0,0 +1,38 @@
/****************************************************************************
* mm/umm_heap/umm_malloc_size.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <malloc.h>
#include <nuttx/mm/mm.h>
/****************************************************************************
* Public Functions
****************************************************************************/
size_t malloc_size(FAR void *mem)
{
return mm_malloc_size(mem);
}