This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b9b015ae35 mm/mm_heap: Allocate the heap structure with malloc().
7b9b015ae35 is described below

commit 7b9b015ae35420913db95656d0e808aeaf018ccf
Author: Marco Casaroli <[email protected]>
AuthorDate: Fri Nov 13 07:30:35 2026 +0100

    mm/mm_heap: Allocate the heap structure with malloc().
    
    Since commit f231a24ae3a ("mm: replace mm_heap_config_s.heap with an
    allocheap flag"), mm_initialize_heap() allocates struct mm_heap_s with
    lib_memalign(MM_ALIGN, ...) when config->allocheap is set.  The call
    links memalign() and mm_memalign() into images that do not use them
    otherwise, also when no caller sets allocheap.  weact-stm32h750:sdcard
    (clang) became 448 bytes larger.
    
    The structure needs only its natural alignment, which malloc() gives.
    In this heap manager, mm_malloc() returns MM_ALIGN-aligned blocks, and
    mm_memalign() calls mm_malloc() for an alignment of MM_ALIGN or less.
    Before f231a24ae3a, this code used mm_malloc().  Use lib_malloc().
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 mm/mm_heap/mm_initialize.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/mm_heap/mm_initialize.c b/mm/mm_heap/mm_initialize.c
index 9d79bd7f81a..b9228410b5f 100644
--- a/mm/mm_heap/mm_initialize.c
+++ b/mm/mm_heap/mm_initialize.c
@@ -267,7 +267,9 @@ mm_initialize_heap(FAR const struct mm_heap_config_s 
*config)
     }
   else
     {
-      heap = lib_memalign(MM_ALIGN, sizeof(struct mm_heap_s));
+      /* malloc() alignment is sufficient, and memalign() adds code */
+
+      heap = lib_malloc(sizeof(struct mm_heap_s));
       if (heap == NULL)
         {
           return NULL;

Reply via email to