summaryrefslogtreecommitdiff
path: root/nuttx/mm/mm_mallinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/mm/mm_mallinfo.c')
-rw-r--r--nuttx/mm/mm_mallinfo.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/nuttx/mm/mm_mallinfo.c b/nuttx/mm/mm_mallinfo.c
index 68c2a7bb7..0e6ae4e78 100644
--- a/nuttx/mm/mm_mallinfo.c
+++ b/nuttx/mm/mm_mallinfo.c
@@ -76,6 +76,11 @@ int mallinfo(struct mallinfo *info)
int ordblks = 0; /* Number of non-inuse chunks */
size_t uordblks = 0; /* Total allocated space */
size_t fordblks = 0; /* Total non-inuse space */
+#if CONFIG_MM_REGIONS > 1
+ int region;
+#else
+# define region 0
+#endif
#ifdef CONFIG_CAN_PASS_STRUCTS
static struct mallinfo info;
@@ -85,29 +90,39 @@ int mallinfo(struct mallinfo *info)
return ERROR;
}
#endif
- /* Visit each node in physical memory */
- for (node = g_heapstart;
- node < g_heapend;
- node = (struct mm_allocnode_s *)((char*)node + node->size))
+ /* Visit each region */
+
+#if CONFIG_MM_REGIONS > 1
+ for (region = 0; region < g_nregions; region++)
+#endif
{
- if (node->preceding & MM_ALLOC_BIT)
- {
- uordblks += node->size;
- }
- else
+ /* Visit each node in the region */
+
+ for (node = g_heapstart[region];
+ node < g_heapend[region];
+ node = (struct mm_allocnode_s *)((char*)node + node->size))
{
- ordblks++;
- fordblks += node->size;
- if (node->size > mxordblk)
+ if (node->preceding & MM_ALLOC_BIT)
{
- mxordblk = node->size;
+ uordblks += node->size;
+ }
+ else
+ {
+ ordblks++;
+ fordblks += node->size;
+ if (node->size > mxordblk)
+ {
+ mxordblk = node->size;
+ }
}
}
+
+ DEBUGASSERT(node == g_heapend[region]);
+ uordblks += SIZEOF_MM_ALLOCNODE; /* account for the tail node */
}
+#undef region
- DEBUGASSERT(node == g_heapend);
- uordblks += SIZEOF_MM_ALLOCNODE; /* account for the tail node */
DEBUGASSERT(uordblks + fordblks == g_heapsize);
#ifdef CONFIG_CAN_PASS_STRUCTS