From: Donald Sharp Date: Fri, 30 Sep 2016 01:47:07 +0000 (-0400) Subject: lib: Only display memory items that have allocations X-Git-Tag: frr-2.0-rc1~208 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=3694c43ac09e03fb34fa8aed6c0e054a295f2414;p=mirror%2Ffrr.git 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 --- 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; }