vppinfra: introduce clib_mem_main

To hold more data later...

Type: improvement
Change-Id: I4006d22dcacd788988c4907f2c263fd4e4a9d398
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vlib/cli.c b/src/vlib/cli.c
index 2697c0a..2bdc98c 100644
--- a/src/vlib/cli.c
+++ b/src/vlib/cli.c
@@ -739,6 +739,7 @@
 show_memory_usage (vlib_main_t * vm,
 		   unformat_input_t * input, vlib_cli_command_t * cmd)
 {
+  clib_mem_main_t *mm = &clib_mem_main;
   int verbose __attribute__ ((unused)) = 0;
   int api_segment = 0, stats_segment = 0, main_heap = 0, numa_heaps = 0;
   clib_error_t *error;
@@ -826,7 +827,7 @@
         ({
           struct dlmallinfo mi;
           void *mspace;
-          mspace = clib_per_cpu_mheaps[index];
+          mspace = mm->per_cpu_mheaps[index];
 
           mi = mspace_mallinfo (mspace);
           vlib_cli_output (vm, "%sThread %d %s\n", index ? "\n":"", index,
@@ -835,7 +836,7 @@
                            pointer_to_uword (mspace_least_addr(mspace)),
                            mi.arena);
           vlib_cli_output (vm, "  %U\n", format_mheap,
-                           clib_per_cpu_mheaps[index],
+                           mm->per_cpu_mheaps[index],
                            verbose);
           index++;
         }));
@@ -849,17 +850,17 @@
 	struct dlmallinfo mi;
 	void *mspace;
 
-	for (i = 0; i < ARRAY_LEN (clib_per_numa_mheaps); i++)
+	for (i = 0; i < ARRAY_LEN (mm->per_numa_mheaps); i++)
 	  {
-	    if (clib_per_numa_mheaps[i] == 0)
+	    if (mm->per_numa_mheaps[i] == 0)
 	      continue;
-	    if (clib_per_numa_mheaps[i] == clib_per_cpu_mheaps[i])
+	    if (mm->per_numa_mheaps[i] == mm->per_cpu_mheaps[i])
 	      {
 		vlib_cli_output (vm, "Numa %d uses the main heap...", i);
 		continue;
 	      }
 	    was_enabled = clib_mem_trace_enable_disable (0);
-	    mspace = clib_per_numa_mheaps[i];
+	    mspace = mm->per_numa_mheaps[i];
 
 	    mi = mspace_mallinfo (mspace);
 	    vlib_cli_output (vm, "Numa %d:", i);
@@ -867,7 +868,7 @@
 			     pointer_to_uword (mspace_least_addr (mspace)),
 			     mi.arena);
 	    vlib_cli_output (vm, "  %U\n", format_mheap,
-			     clib_per_numa_mheaps[index], verbose);
+			     mm->per_numa_mheaps[index], verbose);
 	  }
       }
   }
@@ -921,6 +922,7 @@
 			     unformat_input_t * input,
 			     vlib_cli_command_t * cmd)
 {
+  clib_mem_main_t *mm = &clib_mem_main;
   unformat_input_t _line_input, *line_input = &_line_input;
   int enable = 1;
   int api_segment = 0;
@@ -1003,15 +1005,15 @@
 
   if (numa_id != ~0)
     {
-      if (numa_id >= ARRAY_LEN (clib_per_numa_mheaps))
+      if (numa_id >= ARRAY_LEN (mm->per_numa_mheaps))
 	return clib_error_return (0, "Numa %d out of range", numa_id);
-      if (clib_per_numa_mheaps[numa_id] == 0)
+      if (mm->per_numa_mheaps[numa_id] == 0)
 	return clib_error_return (0, "Numa %d heap not active", numa_id);
 
-      if (clib_per_numa_mheaps[numa_id] == clib_mem_get_heap ())
+      if (mm->per_numa_mheaps[numa_id] == clib_mem_get_heap ())
 	return clib_error_return (0, "Numa %d uses the main heap...",
 				  numa_id);
-      current_traced_heap = clib_per_numa_mheaps[numa_id];
+      current_traced_heap = mm->per_numa_mheaps[numa_id];
       oldheap = clib_mem_set_heap (current_traced_heap);
       clib_mem_trace (1);
       clib_mem_set_heap (oldheap);