/mm/mm_heap/mm_mallinfo.c: Fix assertion broken in 312ea9f9.

This commit is contained in:
Juha Niskanen
2020-02-17 08:06:46 -06:00
committed by Gregory Nutt
parent 5ebce26cc7
commit ea72d84c4d
+7 -3
View File
@@ -61,7 +61,7 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
{ {
FAR struct mm_allocnode_s *node; FAR struct mm_allocnode_s *node;
#ifdef CONFIG_DEBUG_ASSERTIONS #ifdef CONFIG_DEBUG_ASSERTIONS
FAR struct mm_allocnode_s *prev = NULL; FAR struct mm_allocnode_s *prev;
#endif #endif
size_t mxordblk = 0; size_t mxordblk = 0;
int ordblks = 0; /* Number of non-inuse chunks */ int ordblks = 0; /* Number of non-inuse chunks */
@@ -81,6 +81,9 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
for (region = 0; region < heap->mm_nregions; region++) for (region = 0; region < heap->mm_nregions; region++)
#endif #endif
{ {
#ifdef CONFIG_DEBUG_ASSERTIONS
prev = NULL;
#endif
/* Visit each node in the region /* Visit each node in the region
* Retake the semaphore for each region to reduce latencies * Retake the semaphore for each region to reduce latencies
*/ */
@@ -124,11 +127,12 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
mxordblk = node->size; mxordblk = node->size;
} }
} }
DEBUGASSERT(prev == NULL ||
prev->size == (node->preceding & ~MM_ALLOC_BIT));
#ifdef CONFIG_DEBUG_ASSERTIONS #ifdef CONFIG_DEBUG_ASSERTIONS
prev = node; prev = node;
#endif #endif
DEBUGASSERT(prev == NULL ||
prev->size == (node->preceding & ~MM_ALLOC_BIT));
} }
minfo("region=%d node=%p heapend=%p\n", minfo("region=%d node=%p heapend=%p\n",