From 2f57f353e8d0b761884303f49e0c2a937b7d6243 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Thu, 25 Oct 2012 18:56:47 -0700 Subject: [PATCH] [master] address mem.c compilation problems 3406. [bug] mem.c: Fix compilation errors when building with ISC_MEM_TRACKLINES or ISC_MEMPOOL_NAMES disabled. Also, ISC_MEM_DEBUG is no longer optional. [RT #31559] --- CHANGES | 4 ++++ lib/isc/include/isc/mem.h | 17 ----------------- lib/isc/include/isc/namespace.h | 1 + lib/isc/mem.c | 21 ++++++++++++++++----- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/CHANGES b/CHANGES index 8046ecfaeb..b5a0aab72b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +3406. [bug] mem.c: Fix compilation errors when building with + ISC_MEM_TRACKLINES or ISC_MEMPOOL_NAMES disabled. + Also, ISC_MEM_DEBUG is no longer optional. [RT #31559] + 3405. [bug] Handle time going backwards in acache. [RT #31253] 3404. [bug] dnssec-signzone: When re-signing a zone, remove diff --git a/lib/isc/include/isc/mem.h b/lib/isc/include/isc/mem.h index 07fcc1a58b..ca5e1bbd58 100644 --- a/lib/isc/include/isc/mem.h +++ b/lib/isc/include/isc/mem.h @@ -39,15 +39,6 @@ typedef void (*isc_mem_water_t)(void *, int); typedef void * (*isc_memalloc_t)(void *, size_t); typedef void (*isc_memfree_t)(void *, void *); -/*% - * Define ISC_MEM_DEBUG=1 to make all functions that free memory - * set the pointer being freed to NULL after being freed. - * This is the default; set ISC_MEM_DEBUG=0 to disable it. - */ -#ifndef ISC_MEM_DEBUG -#define ISC_MEM_DEBUG 1 -#endif - /*% * Define ISC_MEM_TRACKLINES=1 to turn on detailed tracing of memory * allocation and freeing by file and line number. @@ -276,7 +267,6 @@ struct isc_mempool { #define ISCAPI_MPOOL_VALID(mp) ((mp) != NULL && \ (mp)->magic == ISCAPI_MPOOL_MAGIC) -#if ISC_MEM_DEBUG #define isc_mem_put(c, p, s) \ do { \ ISCMEMFUNC(put)((c), (p), (s) _ISC_MEM_FILELINE); \ @@ -297,13 +287,6 @@ struct isc_mempool { ISCMEMPOOLFUNC(put)((c), (p) _ISC_MEM_FILELINE); \ (p) = NULL; \ } while (0) -#else -#define isc_mem_put(c, p, s) ISCMEMFUNC(put)((c), (p), (s) _ISC_MEM_FILELINE) -#define isc_mem_putanddetach(c, p, s) \ - ISCMEMFUNC(putanddetach)((c), (p), (s) _ISC_MEM_FILELINE) -#define isc_mem_free(c, p) ISCMEMFUNC(free)((c), (p) _ISC_MEM_FILELINE) -#define isc_mempool_put(c, p) ISCMEMPOOLFUNC(put)((c), (p) _ISC_MEM_FILELINE) -#endif /*@{*/ isc_result_t diff --git a/lib/isc/include/isc/namespace.h b/lib/isc/include/isc/namespace.h index 1dbb1a766b..b3a863e182 100644 --- a/lib/isc/include/isc/namespace.h +++ b/lib/isc/include/isc/namespace.h @@ -73,6 +73,7 @@ #define isc_mem_isovermem isc__mem_isovermem #define isc_mem_setname isc__mem_setname #define isc_mem_setwater isc__mem_setwater +#define isc_mem_printactive isc__mem_printactive #define isc_mem_printallactive isc__mem_printallactive #define isc_mem_waterack isc__mem_waterack #define isc_mempool_create isc__mempool_create diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 8ca081cf8c..c9c625a39c 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -202,6 +202,7 @@ struct isc__mempool { #if ! ISC_MEM_TRACKLINES #define ADD_TRACE(a, b, c, d, e) #define DELETE_TRACE(a, b, c, d, e) +#define ISC_MEMFUNC_SCOPE #else #define ADD_TRACE(a, b, c, d, e) \ do { \ @@ -325,6 +326,7 @@ isc__mem_checkdestroyed(FILE *file); ISC_MEMFUNC_SCOPE unsigned int isc__mem_references(isc_mem_t *ctx0); #endif +#endif /* ISC_MEM_TRACKLINES */ static struct isc__memmethods { isc_memmethods_t methods; @@ -395,6 +397,7 @@ static struct isc__mempoolmethods { #endif }; +#if ISC_MEM_TRACKLINES /*! * mctx must be locked. */ @@ -1484,7 +1487,12 @@ isc__mem_stats(isc_mem_t *ctx0, FILE *out) { } while (pool != NULL) { fprintf(out, "%15s %10lu %10u %10u %10u %10u %10u %10u %s\n", - pool->name, (unsigned long) pool->size, pool->maxalloc, +#if ISC_MEMPOOL_NAMES + pool->name, +#else + "(not tracked)", +#endif + (unsigned long) pool->size, pool->maxalloc, pool->allocated, pool->freecount, pool->freemax, pool->fillcount, pool->gets, (pool->lock == NULL ? "N" : "Y")); @@ -2296,16 +2304,16 @@ isc__mem_register() { #ifdef BIND9 ISC_MEMFUNC_SCOPE void isc__mem_printactive(isc_mem_t *ctx0, FILE *file) { +#if ISC_MEM_TRACKLINES isc__mem_t *ctx = (isc__mem_t *)ctx0; REQUIRE(VALID_CONTEXT(ctx)); REQUIRE(file != NULL); -#if !ISC_MEM_TRACKLINES - UNUSED(ctx); - UNUSED(file); -#else print_active(ctx, file); +#else + UNUSED(ctx0); + UNUSED(file); #endif } @@ -2331,6 +2339,9 @@ isc__mem_printallactive(FILE *file) { ISC_MEMFUNC_SCOPE void isc__mem_checkdestroyed(FILE *file) { +#if !ISC_MEM_TRACKLINES + UNUSED(file); +#endif RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);