From 3694c43ac09e03fb34fa8aed6c0e054a295f2414 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 29 Sep 2016 21:47:07 -0400 Subject: [PATCH] lib: Only display memory items that have allocations When displaying memory via a 'show run' only display items that have actual memory allocated. Signed-off-by: Donald Sharp --- lib/memory_vty.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/memory_vty.c b/lib/memory_vty.c index e4cb295cf0..73acafe23b 100644 --- a/lib/memory_vty.c +++ b/lib/memory_vty.c @@ -82,13 +82,15 @@ static int qmem_walker(void *arg, struct memgroup *mg, struct memtype *mt) if (!mt) vty_out (vty, "--- qmem %s ---%s", mg->name, VTY_NEWLINE); else { - char size[32]; - snprintf(size, sizeof(size), "%6zu", mt->size); - vty_out (vty, "%-30s: %10zu %s%s", - mt->name, mt->n_alloc, - mt->size == 0 ? "" : - mt->size == SIZE_VAR ? "(variably sized)" : - size, VTY_NEWLINE); + if (mt->n_alloc != 0) { + char size[32]; + snprintf(size, sizeof(size), "%6zu", mt->size); + vty_out (vty, "%-30s: %10zu %s%s", + mt->name, mt->n_alloc, + mt->size == 0 ? "" : + mt->size == SIZE_VAR ? "(variably sized)" : + size, VTY_NEWLINE); + } } return 0; } -- 2.39.5