From 11e6254179cb78412f40d2a263bf4fb40dd7f2ff Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Wed, 10 Jun 2020 20:04:01 +0200 Subject: Improve memdebug, add basic proxy stats --- utils.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'utils.h') diff --git a/utils.h b/utils.h index 2eeb5d4..52a1078 100644 --- a/utils.h +++ b/utils.h @@ -79,13 +79,17 @@ static inline bool list_empty(struct list_head *list) &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) -#define zmalloc(s) ({ fprintf(stderr, "Alloc: zmalloc called from %s: %zu\n", __func__, s); __zmalloc(s); }) -void *__zmalloc(size_t s); +#define zmalloc(s) __zmalloc(__func__, __LINE__, s) +void *__zmalloc(const char *fn, int line, size_t s); -#define xstrdup(s) ({ fprintf(stderr, "Alloc: xstrdup called from %s: %zu\n", __func__, strlen(s) + 1); __xstrdup(s); }) -char *__xstrdup(const char *s); +#define xstrdup(s) __xstrdup(__func__, __LINE__, s) +char *__xstrdup(const char *fn, int line, const char *s); -void xfree(void *ptr); +#define xstrndup(s, n) __xstrndup(__func__, __LINE__, s, n) +char *__xstrndup(const char *fn, int line, const char *s, size_t n); + +#define xfree(s) __xfree(__func__, __LINE__, s) +void __xfree(const char *fn, int line, void *ptr); void debug_resource_usage(); -- cgit v1.2.3