summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ChangeLog8
-rw-r--r--lib/memory.c34
2 files changed, 31 insertions, 11 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 51646138..c94e5639 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -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).
diff --git a/lib/memory.c b/lib/memory.c
index 8ddf3f4d..dae2b9ae 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -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;