Skip to content

Commit

Permalink
lib: print backtrace on MTYPE count underflow
Browse files Browse the repository at this point in the history
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
  • Loading branch information
eqvinox committed Feb 7, 2017
1 parent 62fb7b1 commit f65e2d4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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--;
}

Expand Down

0 comments on commit f65e2d4

Please sign in to comment.