From f8dbd659d097e5265fbff8b45fb718f2bada8d98 Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Thu, 6 Sep 2001 23:03:01 +0000 Subject: [PATCH] When ISC_MEM_TRACKLINES=1, don't calle {add,delete}_trace_entry() for every alloc/free if neither ISC_MEM_DEBUGTRACE nor ISC_MEM_DEBUGRECORD is turned on. This removes my last objection to setting ISC_MEM_TRACKLINES=1 by default. --- lib/isc/mem.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 6e848f6fe5..d0d048204c 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mem.c,v 1.101 2001/09/05 06:26:07 marka Exp $ */ +/* $Id: mem.c,v 1.102 2001/09/06 23:03:01 gson Exp $ */ #include @@ -186,11 +186,14 @@ struct isc_mempool { #define DELETE_TRACE(a, b, c, d, e) #else #define ADD_TRACE(a, b, c, d, e) \ - do { if (b != NULL) add_trace_entry(a, b, c, d, e); } while (0) + do { \ + if ((isc_mem_debugging & (ISC_MEM_DEBUGTRACE | \ + ISC_MEM_DEBUGRECORD)) != 0 && \ + b != NULL) \ + add_trace_entry(a, b, c, d, e); \ + } while (0) #define DELETE_TRACE(a, b, c, d, e) delete_trace_entry(a, b, c, d, e) -#define MEM_TRACE ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) - static void print_active(isc_mem_t *ctx, FILE *out); @@ -204,7 +207,7 @@ add_trace_entry(isc_mem_t *mctx, const void *ptr, unsigned int size debuglink_t *dl; unsigned int i; - if (MEM_TRACE) + if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) fprintf(stderr, isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, ISC_MSG_ADDTRACE, "add %p size %u " @@ -259,7 +262,7 @@ delete_trace_entry(isc_mem_t *mctx, const void *ptr, unsigned int size, debuglink_t *dl; unsigned int i; - if (MEM_TRACE) + if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) fprintf(stderr, isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, ISC_MSG_DELTRACE, "del %p size %u " @@ -1231,8 +1234,7 @@ isc__mem_allocate(isc_mem_t *ctx, size_t size FLARG) { #endif /* ISC_MEM_USE_INTERNAL_MALLOC */ #if ISC_MEM_TRACKLINES - if (si != NULL) - ADD_TRACE(ctx, si, si[-1].u.size, file, line); + ADD_TRACE(ctx, si, si[-1].u.size, file, line); #endif UNLOCK(&ctx->lock);