From cab7429706aa6fce9d217ba6c5e3b6e5557914d5 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Tue, 16 Jun 2020 11:22:46 +0200 Subject: Cleanup debugging macros a bit --- utils.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'utils.c') diff --git a/utils.c b/utils.c index 56b75a5..20c4802 100644 --- a/utils.c +++ b/utils.c @@ -36,8 +36,9 @@ add_allocation(const char *allocfn, const char *callerfn, int line, void *ptr, s { struct allocation *a = malloc(sizeof(*a)); - fprintf(stderr, "Allocation: %s:%i %s(%zu) = %p\n", - callerfn, line, allocfn, size, ptr); + debug(DBG_MALLOC, "%s:%i %s(%zu) = %p\n", + callerfn, line, allocfn, size, ptr); + a->allocfn = allocfn; a->callerfn = callerfn; a->line = line; @@ -98,7 +99,8 @@ __xfree(const char *fn, int line, void *ptr) free(ptr); malloc_count--; - fprintf(stderr, "Deallocation: %s:%i %p\n", fn, line, ptr); + debug(DBG_MALLOC, "%s:%i %p\n", fn, line, ptr); + list_for_each_entry_safe(a, tmp, &malloc_list, list) { if (a->ptr == ptr) { list_del(&a->list); -- cgit v1.2.3