]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: print backtrace on MTYPE count underflow
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 7 Feb 2017 15:23:38 +0000 (16:23 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 7 Feb 2017 15:23:38 +0000 (16:23 +0100)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/memory.c

index f17915486c1fa2034394c99f01b26fc870b55c08..5fc008810523b010b6e484fcff8dfa7b354d3682 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 
 #include "memory.h"
+#include "log.h"
 
 static struct memgroup *mg_first = NULL;
 struct memgroup **mg_insert = &mg_first;
@@ -40,6 +41,11 @@ mt_count_alloc (struct memtype *mt, size_t size)
 static inline void
 mt_count_free (struct memtype *mt)
 {
+  if (mt->n_alloc == 0)
+    {
+      zlog_err ("memory allocation count underflow for \"%s\"", mt->name);
+      zlog_backtrace (LOG_ERR);
+    }
   mt->n_alloc--;
 }