9832fd
commit 987c02692a88b8c9024cb99187434aad02c3c047
9832fd
Author: Ondřej Bílka <neleai@seznam.cz>
9832fd
Date:   Fri May 30 13:24:56 2014 +0200
9832fd
9832fd
    Remove mi_arena nested function.
9832fd
9832fd
diff --git a/malloc/malloc.c b/malloc/malloc.c
9832fd
index 5c7a27129d66e06a..c99b26d4a85e1b22 100644
9832fd
--- a/malloc/malloc.c
9832fd
+++ b/malloc/malloc.c
9832fd
@@ -5023,147 +5023,143 @@ malloc_info (int options, FILE *fp)
9832fd
   size_t total_aspace = 0;
9832fd
   size_t total_aspace_mprotect = 0;
9832fd
 
9832fd
-  void
9832fd
-  mi_arena (mstate ar_ptr)
9832fd
-  {
9832fd
-    fprintf (fp, "<heap nr=\"%d\">\n<sizes>\n", n++);
9832fd
 
9832fd
-    size_t nblocks = 0;
9832fd
-    size_t nfastblocks = 0;
9832fd
-    size_t avail = 0;
9832fd
-    size_t fastavail = 0;
9832fd
-    struct
9832fd
-    {
9832fd
-      size_t from;
9832fd
-      size_t to;
9832fd
-      size_t total;
9832fd
-      size_t count;
9832fd
-    } sizes[NFASTBINS + NBINS - 1];
9832fd
-#define nsizes (sizeof (sizes) / sizeof (sizes[0]))
9832fd
 
9832fd
-    mutex_lock (&ar_ptr->mutex);
9832fd
+  if (__malloc_initialized < 0)
9832fd
+    ptmalloc_init ();
9832fd
+
9832fd
+  fputs ("<malloc version=\"1\">\n", fp);
9832fd
+
9832fd
+  /* Iterate over all arenas currently in use.  */
9832fd
+  mstate ar_ptr = &main_arena;
9832fd
+  do
9832fd
+    {
9832fd
+      fprintf (fp, "<heap nr=\"%d\">\n<sizes>\n", n++);
9832fd
 
9832fd
-    for (size_t i = 0; i < NFASTBINS; ++i)
9832fd
+      size_t nblocks = 0;
9832fd
+      size_t nfastblocks = 0;
9832fd
+      size_t avail = 0;
9832fd
+      size_t fastavail = 0;
9832fd
+      struct
9832fd
       {
9832fd
-        mchunkptr p = fastbin (ar_ptr, i);
9832fd
-        if (p != NULL)
9832fd
-          {
9832fd
-            size_t nthissize = 0;
9832fd
-            size_t thissize = chunksize (p);
9832fd
-
9832fd
-            while (p != NULL)
9832fd
-              {
9832fd
-                ++nthissize;
9832fd
-                p = p->fd;
9832fd
-              }
9832fd
-
9832fd
-            fastavail += nthissize * thissize;
9832fd
-            nfastblocks += nthissize;
9832fd
-            sizes[i].from = thissize - (MALLOC_ALIGNMENT - 1);
9832fd
-            sizes[i].to = thissize;
9832fd
-            sizes[i].count = nthissize;
9832fd
-          }
9832fd
-        else
9832fd
-          sizes[i].from = sizes[i].to = sizes[i].count = 0;
9832fd
-
9832fd
-        sizes[i].total = sizes[i].count * sizes[i].to;
9832fd
-      }
9832fd
+	size_t from;
9832fd
+	size_t to;
9832fd
+	size_t total;
9832fd
+	size_t count;
9832fd
+      } sizes[NFASTBINS + NBINS - 1];
9832fd
+#define nsizes (sizeof (sizes) / sizeof (sizes[0]))
9832fd
 
9832fd
+      mutex_lock (&ar_ptr->mutex);
9832fd
 
9832fd
-    mbinptr bin;
9832fd
-    struct malloc_chunk *r;
9832fd
+      for (size_t i = 0; i < NFASTBINS; ++i)
9832fd
+	{
9832fd
+	  mchunkptr p = fastbin (ar_ptr, i);
9832fd
+	  if (p != NULL)
9832fd
+	    {
9832fd
+	      size_t nthissize = 0;
9832fd
+	      size_t thissize = chunksize (p);
9832fd
+
9832fd
+	      while (p != NULL)
9832fd
+		{
9832fd
+		  ++nthissize;
9832fd
+		  p = p->fd;
9832fd
+		}
9832fd
+
9832fd
+	      fastavail += nthissize * thissize;
9832fd
+	      nfastblocks += nthissize;
9832fd
+	      sizes[i].from = thissize - (MALLOC_ALIGNMENT - 1);
9832fd
+	      sizes[i].to = thissize;
9832fd
+	      sizes[i].count = nthissize;
9832fd
+	    }
9832fd
+	  else
9832fd
+	    sizes[i].from = sizes[i].to = sizes[i].count = 0;
9832fd
 
9832fd
-    for (size_t i = 1; i < NBINS; ++i)
9832fd
-      {
9832fd
-        bin = bin_at (ar_ptr, i);
9832fd
-        r = bin->fd;
9832fd
-        sizes[NFASTBINS - 1 + i].from = ~((size_t) 0);
9832fd
-        sizes[NFASTBINS - 1 + i].to = sizes[NFASTBINS - 1 + i].total
9832fd
-                                        = sizes[NFASTBINS - 1 + i].count = 0;
9832fd
-
9832fd
-        if (r != NULL)
9832fd
-          while (r != bin)
9832fd
-            {
9832fd
-              ++sizes[NFASTBINS - 1 + i].count;
9832fd
-              sizes[NFASTBINS - 1 + i].total += r->size;
9832fd
-              sizes[NFASTBINS - 1 + i].from
9832fd
-                = MIN (sizes[NFASTBINS - 1 + i].from, r->size);
9832fd
-              sizes[NFASTBINS - 1 + i].to = MAX (sizes[NFASTBINS - 1 + i].to,
9832fd
-                                                 r->size);
9832fd
-
9832fd
-              r = r->fd;
9832fd
-            }
9832fd
-
9832fd
-        if (sizes[NFASTBINS - 1 + i].count == 0)
9832fd
-          sizes[NFASTBINS - 1 + i].from = 0;
9832fd
-        nblocks += sizes[NFASTBINS - 1 + i].count;
9832fd
-        avail += sizes[NFASTBINS - 1 + i].total;
9832fd
-      }
9832fd
+	  sizes[i].total = sizes[i].count * sizes[i].to;
9832fd
+	}
9832fd
 
9832fd
-    mutex_unlock (&ar_ptr->mutex);
9832fd
 
9832fd
-    total_nfastblocks += nfastblocks;
9832fd
-    total_fastavail += fastavail;
9832fd
+      mbinptr bin;
9832fd
+      struct malloc_chunk *r;
9832fd
 
9832fd
-    total_nblocks += nblocks;
9832fd
-    total_avail += avail;
9832fd
+      for (size_t i = 1; i < NBINS; ++i)
9832fd
+	{
9832fd
+	  bin = bin_at (ar_ptr, i);
9832fd
+	  r = bin->fd;
9832fd
+	  sizes[NFASTBINS - 1 + i].from = ~((size_t) 0);
9832fd
+	  sizes[NFASTBINS - 1 + i].to = sizes[NFASTBINS - 1 + i].total
9832fd
+					  = sizes[NFASTBINS - 1 + i].count = 0;
9832fd
+
9832fd
+	  if (r != NULL)
9832fd
+	    while (r != bin)
9832fd
+	      {
9832fd
+		++sizes[NFASTBINS - 1 + i].count;
9832fd
+		sizes[NFASTBINS - 1 + i].total += r->size;
9832fd
+		sizes[NFASTBINS - 1 + i].from
9832fd
+		  = MIN (sizes[NFASTBINS - 1 + i].from, r->size);
9832fd
+		sizes[NFASTBINS - 1 + i].to = MAX (sizes[NFASTBINS - 1 + i].to,
9832fd
+						   r->size);
9832fd
+
9832fd
+		r = r->fd;
9832fd
+	      }
9832fd
 
9832fd
-    for (size_t i = 0; i < nsizes; ++i)
9832fd
-      if (sizes[i].count != 0 && i != NFASTBINS)
9832fd
-        fprintf (fp, "							      \
9832fd
-<size from=\"%zu\" to=\"%zu\" total=\"%zu\" count=\"%zu\"/>\n",
9832fd
-                 sizes[i].from, sizes[i].to, sizes[i].total, sizes[i].count);
9832fd
+	  if (sizes[NFASTBINS - 1 + i].count == 0)
9832fd
+	    sizes[NFASTBINS - 1 + i].from = 0;
9832fd
+	  nblocks += sizes[NFASTBINS - 1 + i].count;
9832fd
+	  avail += sizes[NFASTBINS - 1 + i].total;
9832fd
+	}
9832fd
 
9832fd
-    if (sizes[NFASTBINS].count != 0)
9832fd
-      fprintf (fp, "\
9832fd
-<unsorted from=\"%zu\" to=\"%zu\" total=\"%zu\" count=\"%zu\"/>\n",
9832fd
-               sizes[NFASTBINS].from, sizes[NFASTBINS].to,
9832fd
-               sizes[NFASTBINS].total, sizes[NFASTBINS].count);
9832fd
+      mutex_unlock (&ar_ptr->mutex);
9832fd
 
9832fd
-    total_system += ar_ptr->system_mem;
9832fd
-    total_max_system += ar_ptr->max_system_mem;
9832fd
+      total_nfastblocks += nfastblocks;
9832fd
+      total_fastavail += fastavail;
9832fd
 
9832fd
-    fprintf (fp,
9832fd
-             "</sizes>\n<total type=\"fast\" count=\"%zu\" size=\"%zu\"/>\n"
9832fd
-             "<total type=\"rest\" count=\"%zu\" size=\"%zu\"/>\n"
9832fd
-             "<system type=\"current\" size=\"%zu\"/>\n"
9832fd
-             "<system type=\"max\" size=\"%zu\"/>\n",
9832fd
-             nfastblocks, fastavail, nblocks, avail,
9832fd
-             ar_ptr->system_mem, ar_ptr->max_system_mem);
9832fd
+      total_nblocks += nblocks;
9832fd
+      total_avail += avail;
9832fd
 
9832fd
-    if (ar_ptr != &main_arena)
9832fd
-      {
9832fd
-        heap_info *heap = heap_for_ptr (top (ar_ptr));
9832fd
-        fprintf (fp,
9832fd
-                 "<aspace type=\"total\" size=\"%zu\"/>\n"
9832fd
-                 "<aspace type=\"mprotect\" size=\"%zu\"/>\n",
9832fd
-                 heap->size, heap->mprotect_size);
9832fd
-        total_aspace += heap->size;
9832fd
-        total_aspace_mprotect += heap->mprotect_size;
9832fd
-      }
9832fd
-    else
9832fd
-      {
9832fd
-        fprintf (fp,
9832fd
-                 "<aspace type=\"total\" size=\"%zu\"/>\n"
9832fd
-                 "<aspace type=\"mprotect\" size=\"%zu\"/>\n",
9832fd
-                 ar_ptr->system_mem, ar_ptr->system_mem);
9832fd
-        total_aspace += ar_ptr->system_mem;
9832fd
-        total_aspace_mprotect += ar_ptr->system_mem;
9832fd
-      }
9832fd
+      for (size_t i = 0; i < nsizes; ++i)
9832fd
+	if (sizes[i].count != 0 && i != NFASTBINS)
9832fd
+	  fprintf (fp, "							      \
9832fd
+  <size from=\"%zu\" to=\"%zu\" total=\"%zu\" count=\"%zu\"/>\n",
9832fd
+		   sizes[i].from, sizes[i].to, sizes[i].total, sizes[i].count);
9832fd
 
9832fd
-    fputs ("</heap>\n", fp);
9832fd
-  }
9832fd
+      if (sizes[NFASTBINS].count != 0)
9832fd
+	fprintf (fp, "\
9832fd
+  <unsorted from=\"%zu\" to=\"%zu\" total=\"%zu\" count=\"%zu\"/>\n",
9832fd
+		 sizes[NFASTBINS].from, sizes[NFASTBINS].to,
9832fd
+		 sizes[NFASTBINS].total, sizes[NFASTBINS].count);
9832fd
 
9832fd
-  if (__malloc_initialized < 0)
9832fd
-    ptmalloc_init ();
9832fd
+      total_system += ar_ptr->system_mem;
9832fd
+      total_max_system += ar_ptr->max_system_mem;
9832fd
 
9832fd
-  fputs ("<malloc version=\"1\">\n", fp);
9832fd
+      fprintf (fp,
9832fd
+	       "</sizes>\n<total type=\"fast\" count=\"%zu\" size=\"%zu\"/>\n"
9832fd
+	       "<total type=\"rest\" count=\"%zu\" size=\"%zu\"/>\n"
9832fd
+	       "<system type=\"current\" size=\"%zu\"/>\n"
9832fd
+	       "<system type=\"max\" size=\"%zu\"/>\n",
9832fd
+	       nfastblocks, fastavail, nblocks, avail,
9832fd
+	       ar_ptr->system_mem, ar_ptr->max_system_mem);
9832fd
 
9832fd
-  /* Iterate over all arenas currently in use.  */
9832fd
-  mstate ar_ptr = &main_arena;
9832fd
-  do
9832fd
-    {
9832fd
-      mi_arena (ar_ptr);
9832fd
+      if (ar_ptr != &main_arena)
9832fd
+	{
9832fd
+	  heap_info *heap = heap_for_ptr (top (ar_ptr));
9832fd
+	  fprintf (fp,
9832fd
+		   "<aspace type=\"total\" size=\"%zu\"/>\n"
9832fd
+		   "<aspace type=\"mprotect\" size=\"%zu\"/>\n",
9832fd
+		   heap->size, heap->mprotect_size);
9832fd
+	  total_aspace += heap->size;
9832fd
+	  total_aspace_mprotect += heap->mprotect_size;
9832fd
+	}
9832fd
+      else
9832fd
+	{
9832fd
+	  fprintf (fp,
9832fd
+		   "<aspace type=\"total\" size=\"%zu\"/>\n"
9832fd
+		   "<aspace type=\"mprotect\" size=\"%zu\"/>\n",
9832fd
+		   ar_ptr->system_mem, ar_ptr->system_mem);
9832fd
+	  total_aspace += ar_ptr->system_mem;
9832fd
+	  total_aspace_mprotect += ar_ptr->system_mem;
9832fd
+	}
9832fd
+
9832fd
+      fputs ("</heap>\n", fp);
9832fd
       ar_ptr = ar_ptr->next;
9832fd
     }
9832fd
   while (ar_ptr != &main_arena);