yamt commented on code in PR #5991:
URL: https://github.com/apache/incubator-nuttx/pull/5991#discussion_r845629927
##########
mm/mm_heap/mm_initialize.c:
##########
@@ -93,12 +93,17 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void
*heapstart,
DEBUGVERIFY(mm_takesemaphore(heap));
- /* Adjust the provided heap start and size so that they are both aligned
- * with the MM_MIN_CHUNK size.
+ /* Adjust the provided heap start and size.
+ *
+ * Note: (uintptr_t)node + SIZEOF_MM_ALLOCNODE is what's actually
+ * returned to the malloc user, which should have natural alignment.
+ * (that is, in this implementation, MM_MIN_CHUNK-alignment.)
*/
- heapbase = MM_ALIGN_UP((uintptr_t)heapstart);
- heapend = MM_ALIGN_DOWN((uintptr_t)heapstart + (uintptr_t)heapsize);
+ heapbase = MM_ALIGN_UP((uintptr_t)heapstart + SIZEOF_MM_ALLOCNODE)
+ - SIZEOF_MM_ALLOCNODE;
+ heapend = MM_ALIGN_DOWN((uintptr_t)heapstart + (uintptr_t)heapsize)
Review Comment:
i don't understand your suggestion. the original patch already has `-
SIZEOF_MM_ALLOCNODE`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]