]> git.puffer.fish Git - mirror/frr.git/commitdiff
2005-10-20 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
authorajs <ajs>
Thu, 20 Oct 2005 22:28:14 +0000 (22:28 +0000)
committerajs <ajs>
Thu, 20 Oct 2005 22:28:14 +0000 (22:28 +0000)
* memory.c: (show_memory_vty) Omit zero statistics.  Print separators
  only if some non-zero stats have been printed in between.
  (show_separator) New function to print a separator.
  (show_memory_all) Keep track of whether a separator is needed
  between the different memory statistics groups.

lib/ChangeLog
lib/memory.c

index 516461388b21b2ec7335324a40197ee4650fc2fa..c94e5639ca0d1ccf61c7c7c8c56bb6045c1d3fac 100644 (file)
@@ -1,3 +1,11 @@
+2005-10-20 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+       * memory.c: (show_memory_vty) Omit zero statistics.  Print separators
+         only if some non-zero stats have been printed in between.
+         (show_separator) New function to print a separator.
+         (show_memory_all) Keep track of whether a separator is needed
+         between the different memory statistics groups.
+
 2005-10-18 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
        * memtypes.h: Add MTYPE_OSPF_VERTEX_PARENT (to match memtypes.c).
index 8ddf3f4d7bc1a06493aef5ced15fd86698bd484b..dae2b9aebf949d7b9ce4049b7f227ea8629e4c72 100644 (file)
@@ -249,22 +249,33 @@ log_memstats(int pri)
     }
 }
 
-static struct memory_list memory_list_separator[] =
+static void
+show_separator(struct vty *vty)
 {
-  { 0, NULL},
-  {-1, NULL}
-};
+  vty_out (vty, "-----------------------------\r\n");
+}
 
-static void
+static int
 show_memory_vty (struct vty *vty, struct memory_list *list)
 {
   struct memory_list *m;
+  int needsep = 0;
 
   for (m = list; m->index >= 0; m++)
     if (m->index == 0)
-      vty_out (vty, "-----------------------------\r\n");
-    else
-      vty_out (vty, "%-30s: %10ld\r\n", m->format, mstat[m->index].alloc);
+      {
+       if (needsep)
+         {
+           show_separator (vty);
+           needsep = 0;
+         }
+      }
+    else if (mstat[m->index].alloc)
+      {
+       vty_out (vty, "%-30s: %10ld\r\n", m->format, mstat[m->index].alloc);
+       needsep = 1;
+      }
+  return needsep;
 }
 
 DEFUN (show_memory_all,
@@ -275,12 +286,13 @@ DEFUN (show_memory_all,
        "All memory statistics\n")
 {
   struct mlist *ml;
+  int needsep = 0;
 
   for (ml = mlists; ml->list; ml++)
     {
-      if (ml != mlists)
-        show_memory_vty (vty, memory_list_separator);
-      show_memory_vty (vty, ml->list);
+      if (needsep)
+       show_separator (vty);
+      needsep = show_memory_vty (vty, ml->list);
     }
 
   return CMD_SUCCESS;