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

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

commit 1c1cf74491b621b10137fa60270c748c59012e8f
Author: ganjing <[email protected]>
AuthorDate: Mon Jan 26 14:35:14 2026 +0800

    mm/tlfs: Account initial size of struct mm_heap_s
    
    and then initialize it.
    
    Signed-off-by: ganjing <[email protected]>
---
 mm/tlsf/mm_tlsf.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c
index 9337d20afa6..54ae44b2840 100644
--- a/mm/tlsf/mm_tlsf.c
+++ b/mm/tlsf/mm_tlsf.c
@@ -1033,6 +1033,9 @@ mm_initialize_heap(FAR const struct mm_heap_config_s 
*config)
       heap = (FAR struct mm_heap_s *)heapstart;
       heapstart += sizeof(struct mm_heap_s);
       heapsize -= sizeof(struct mm_heap_s);
+
+      memset(heap, 0, sizeof(struct mm_heap_s));
+      heap->mm_curused = sizeof(struct mm_heap_s);
     }
   else
     {
@@ -1041,9 +1044,10 @@ mm_initialize_heap(FAR const struct mm_heap_config_s 
*config)
         {
           return NULL;
         }
+
+      memset(heap, 0, sizeof(struct mm_heap_s));
     }
 
-  memset(heap, 0, sizeof(struct mm_heap_s));
   heap->mm_nokasan = config->nokasan;
 
   /* Allocate and create TLSF context */

Reply via email to