summaryrefslogtreecommitdiffstats
path: root/lib/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/memory.c')
-rw-r--r--lib/memory.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/lib/memory.c b/lib/memory.c
index f5d0cba6b..dc09d8a6c 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -127,7 +127,7 @@ zstrdup (int type, const char *str)
static struct
{
const char *name;
- unsigned long alloc;
+ long alloc;
unsigned long t_malloc;
unsigned long c_malloc;
unsigned long t_calloc;
@@ -214,9 +214,9 @@ mtype_zstrdup (const char *file, int line, int type, const char *str)
static struct
{
char *name;
- unsigned long alloc;
+ long alloc;
} mstat [MTYPE_MAX];
-#endif /* MTPYE_LOG */
+#endif /* MEMORY_LOG */
/* Increment allocation counter. */
static void
@@ -253,6 +253,47 @@ log_memstats(int pri)
}
}
+void
+log_memstats_stderr (const char *prefix)
+{
+ struct mlist *ml;
+ struct memory_list *m;
+ int i;
+ int j = 0;
+
+ for (ml = mlists; ml->list; ml++)
+ {
+ i = 0;
+
+ for (m = ml->list; m->index >= 0; m++)
+ if (m->index && mstat[m->index].alloc)
+ {
+ if (!i)
+ fprintf (stderr,
+ "%s: memstats: Current memory utilization in module %s:\n",
+ prefix,
+ ml->name);
+ fprintf (stderr,
+ "%s: memstats: %-30s: %10ld%s\n",
+ prefix,
+ m->format,
+ mstat[m->index].alloc,
+ mstat[m->index].alloc < 0 ? " (REPORT THIS BUG!)" : "");
+ i = j = 1;
+ }
+ }
+
+ if (j)
+ fprintf (stderr,
+ "%s: memstats: NOTE: If configuration exists, utilization may be "
+ "expected.\n",
+ prefix);
+ else
+ fprintf (stderr,
+ "%s: memstats: No remaining tracked memory utilization.\n",
+ prefix);
+}
+
static void
show_separator(struct vty *vty)
{