diff --git a/lib/isc/include/isc/mem.h b/lib/isc/include/isc/mem.h index 7c53c92d9c..a3bb16ec8c 100644 --- a/lib/isc/include/isc/mem.h +++ b/lib/isc/include/isc/mem.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mem.h,v 1.44 2000/09/05 22:20:36 marka Exp $ */ +/* $Id: mem.h,v 1.45 2000/12/01 00:32:02 gson Exp $ */ #ifndef ISC_MEM_H #define ISC_MEM_H 1 @@ -36,26 +36,26 @@ typedef void * (*isc_memalloc_t)(void *, size_t); typedef void (*isc_memfree_t)(void *, void *); /* - * ISC_MEM_DEBUG is defined by default; define ISC_MEM_DEBUGOFF to disable it. + * ISC_MEM_DEBUG is enabled by default; set ISC_MEM_DEBUG=0 to disable it. */ -#if !defined(ISC_MEM_DEBUG) && !defined(ISC_MEM_DEBUGOFF) -#define ISC_MEM_DEBUG +#ifndef ISC_MEM_DEBUG +#define ISC_MEM_DEBUG 1 #endif /* - * Define ISC_MEM_TRACKLINES to turn on detailed tracing of memory allocation + * Define ISC_MEM_TRACKLINES=1 to turn on detailed tracing of memory allocation * and freeing by file and line number. */ -#if 0 -#define ISC_MEM_TRACKLINES +#ifndef ISC_MEM_TRACKLINES +#define ISC_MEM_TRACKLINES 0 #endif /* - * Define ISC_MEM_CHECKOVERRUN to turn on checks for using memory outside + * Define ISC_MEM_CHECKOVERRUN=1 to turn on checks for using memory outside * the requested space. This will increase the size of each allocation. */ -#if 0 -#define ISC_MEM_CHECKOVERRUN +#ifndef ISC_MEM_CHECKOVERRUN +#define ISC_MEM_CHECKOVERRUN 0 #endif /* @@ -64,12 +64,16 @@ typedef void (*isc_memfree_t)(void *, void *); * and the like. On freeing memory, the space is filled with '0xde' for * the same reasons. */ -#define ISC_MEM_FILL +#ifndef ISC_MEM_FILL +#define ISC_MEM_FILL 1 +#endif /* * Define this to turn on memory pool names. */ -#define ISC_MEMPOOL_NAMES +#ifndef ISC_MEMPOOL_NAMES +#define ISC_MEMPOOL_NAMES 1 +#endif /* * _DEBUGTRACE @@ -83,7 +87,7 @@ extern unsigned int isc_mem_debugging; #define ISC_MEM_DEBUGTRACE 0x00000001U #define ISC_MEM_DEBUGRECORD 0x00000002U -#ifdef ISC_MEM_TRACKLINES +#if ISC_MEM_TRACKLINES #define _ISC_MEM_FILELINE , __FILE__, __LINE__ #define _ISC_MEM_FLARG , const char *, int #else @@ -121,7 +125,7 @@ extern unsigned int isc_mem_debugging; * isc_mem_detach(&mctx); */ -#ifdef ISC_MEM_DEBUG +#if ISC_MEM_DEBUG #define isc_mem_put(c, p, s) \ do { \ isc__mem_put((c), (p), (s) _ISC_MEM_FILELINE); \ diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 0dc39860cc..8b6670622c 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.66 2000/11/25 06:40:54 marka Exp $ */ +/* $Id: mem.c,v 1.67 2000/12/01 00:32:00 gson Exp $ */ #include @@ -29,13 +29,8 @@ #include #include -#ifndef ISC_SINGLETHREADED #include #include -#else -#define LOCK(l) -#define UNLOCK(l) -#endif unsigned int isc_mem_debugging = 0; @@ -53,7 +48,7 @@ unsigned int isc_mem_debugging = 0; /* * Types. */ -#ifdef ISC_MEM_TRACKLINES +#if ISC_MEM_TRACKLINES typedef struct debuglink debuglink_t; struct debuglink { ISC_LINK(debuglink_t) link; @@ -124,7 +119,7 @@ struct isc_mem { isc_mem_water_t water; void * water_arg; ISC_LIST(isc_mempool_t) pools; -#ifdef ISC_MEM_TRACKLINES +#if ISC_MEM_TRACKLINES ISC_LIST(debuglink_t) debuglist; #endif }; @@ -150,7 +145,7 @@ struct isc_mempool { /* Stats only. */ unsigned int gets; /* # of requests to this pool */ /* Debugging only. */ -#ifdef ISC_MEMPOOL_NAMES +#if ISC_MEMPOOL_NAMES char name[16]; /* printed name in stats reports */ #endif }; @@ -159,7 +154,7 @@ struct isc_mempool { * Private Inline-able. */ -#ifndef ISC_MEM_TRACKLINES +#if ! ISC_MEM_TRACKLINES #define ADD_TRACE(a, b, c, d, e) #define DELETE_TRACE(a, b, c, d, e) #else @@ -542,7 +537,7 @@ mem_getunlocked(isc_mem_t *ctx, size_t size) { done: -#ifdef ISC_MEM_FILL +#if ISC_MEM_FILL if (ret != NULL) memset(ret, 0xbe, new_size); /* Mnemonic for "beef". */ #endif @@ -558,7 +553,7 @@ mem_putunlocked(isc_mem_t *ctx, void *mem, size_t size) { /* * memput() called on something beyond our upper limit. */ -#ifdef ISC_MEM_FILL +#if ISC_MEM_FILL memset(mem, 0xde, size); /* Mnemonic for "dead". */ #endif (ctx->memfree)(ctx->arg, mem); @@ -570,8 +565,8 @@ mem_putunlocked(isc_mem_t *ctx, void *mem, size_t size) { return; } -#ifdef ISC_MEM_FILL -#ifdef ISC_MEM_CHECKOVERRUN +#if ISC_MEM_FILL +#if ISC_MEM_CHECKOVERRUN check_overrun(mem, size, new_size); #endif memset(mem, 0xde, new_size); /* Mnemonic for "dead". */ @@ -874,7 +869,7 @@ isc_mem_restore(isc_mem_t *ctx) { return (result); } -#if defined(ISC_MEM_FILL) && defined(ISC_MEM_CHECKOVERRUN) +#if ISC_MEM_FILL && ISC_MEM_CHECKOVERRUN static inline void check_overrun(void *mem, size_t size, size_t new_size) { unsigned char *cp; @@ -1328,7 +1323,7 @@ isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp) { mpctx->freemax = 1; mpctx->fillcount = 1; mpctx->gets = 0; -#ifdef ISC_MEMPOOL_NAMES +#if ISC_MEMPOOL_NAMES mpctx->name[0] = 0; #endif mpctx->items = NULL; @@ -1346,7 +1341,7 @@ void isc_mempool_setname(isc_mempool_t *mpctx, const char *name) { REQUIRE(name != NULL); -#ifdef ISC_MEMPOOL_NAMES +#if ISC_MEMPOOL_NAMES if (mpctx->lock != NULL) LOCK(mpctx->lock);