summaryrefslogtreecommitdiff
path: root/lib/memory_vty.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2015-05-27 03:45:30 +0200
committerChristian Franke <nobody@nowhere.ws>2016-09-19 17:52:05 +0200
commit3b4cd7837562cd78fe80bde94f5aa6729b2f755d (patch)
tree236c4d7616d4e5aacede3398ec2975b734929874 /lib/memory_vty.c
parent6ba26ad5d2bc863917914db0d8354eb834bba264 (diff)
lib: add new extensible memory-type handling
This rewrites Quagga's memory per-type allocation counting, without using a fixed global list of types. Instead, source files can declare memory types which get handled through constructor functions called by the dynamic linker during startup. Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> [DL: v3: forgot "nonnull" attribute on XFREE] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/memory_vty.c')
-rw-r--r--lib/memory_vty.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/memory_vty.c b/lib/memory_vty.c
index 8d1a03743e..8084aeba0f 100644
--- a/lib/memory_vty.c
+++ b/lib/memory_vty.c
@@ -397,6 +397,24 @@ show_memory_mallinfo (struct vty *vty)
}
#endif /* HAVE_MALLINFO */
+static int qmem_walker(void *arg, struct memgroup *mg, struct memtype *mt)
+{
+ struct vty *vty = arg;
+ 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);
+ }
+ return 0;
+}
+
+
DEFUN (show_memory,
show_memory_cmd,
"show memory",
@@ -417,6 +435,7 @@ DEFUN (show_memory,
needsep = show_memory_vty (vty, ml->list);
}
+ qmem_walk(qmem_walker, vty);
return CMD_SUCCESS;
}