mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
test the various memory debug flags with #if instead of #ifdef
so that they can be turned off by passing -DISC_MEM_FOO=0 on the compiler command line; removed some historical cruft
This commit is contained in:
parent
9d2c9f7896
commit
c52e5c8ed1
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* 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
|
#ifndef ISC_MEM_H
|
||||||
#define ISC_MEM_H 1
|
#define ISC_MEM_H 1
|
||||||
@ -36,26 +36,26 @@ typedef void * (*isc_memalloc_t)(void *, size_t);
|
|||||||
typedef void (*isc_memfree_t)(void *, void *);
|
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)
|
#ifndef ISC_MEM_DEBUG
|
||||||
#define ISC_MEM_DEBUG
|
#define ISC_MEM_DEBUG 1
|
||||||
#endif
|
#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.
|
* and freeing by file and line number.
|
||||||
*/
|
*/
|
||||||
#if 0
|
#ifndef ISC_MEM_TRACKLINES
|
||||||
#define ISC_MEM_TRACKLINES
|
#define ISC_MEM_TRACKLINES 0
|
||||||
#endif
|
#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.
|
* the requested space. This will increase the size of each allocation.
|
||||||
*/
|
*/
|
||||||
#if 0
|
#ifndef ISC_MEM_CHECKOVERRUN
|
||||||
#define ISC_MEM_CHECKOVERRUN
|
#define ISC_MEM_CHECKOVERRUN 0
|
||||||
#endif
|
#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
|
* and the like. On freeing memory, the space is filled with '0xde' for
|
||||||
* the same reasons.
|
* 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 this to turn on memory pool names.
|
||||||
*/
|
*/
|
||||||
#define ISC_MEMPOOL_NAMES
|
#ifndef ISC_MEMPOOL_NAMES
|
||||||
|
#define ISC_MEMPOOL_NAMES 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _DEBUGTRACE
|
* _DEBUGTRACE
|
||||||
@ -83,7 +87,7 @@ extern unsigned int isc_mem_debugging;
|
|||||||
#define ISC_MEM_DEBUGTRACE 0x00000001U
|
#define ISC_MEM_DEBUGTRACE 0x00000001U
|
||||||
#define ISC_MEM_DEBUGRECORD 0x00000002U
|
#define ISC_MEM_DEBUGRECORD 0x00000002U
|
||||||
|
|
||||||
#ifdef ISC_MEM_TRACKLINES
|
#if ISC_MEM_TRACKLINES
|
||||||
#define _ISC_MEM_FILELINE , __FILE__, __LINE__
|
#define _ISC_MEM_FILELINE , __FILE__, __LINE__
|
||||||
#define _ISC_MEM_FLARG , const char *, int
|
#define _ISC_MEM_FLARG , const char *, int
|
||||||
#else
|
#else
|
||||||
@ -121,7 +125,7 @@ extern unsigned int isc_mem_debugging;
|
|||||||
* isc_mem_detach(&mctx);
|
* isc_mem_detach(&mctx);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef ISC_MEM_DEBUG
|
#if ISC_MEM_DEBUG
|
||||||
#define isc_mem_put(c, p, s) \
|
#define isc_mem_put(c, p, s) \
|
||||||
do { \
|
do { \
|
||||||
isc__mem_put((c), (p), (s) _ISC_MEM_FILELINE); \
|
isc__mem_put((c), (p), (s) _ISC_MEM_FILELINE); \
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* 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 <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -29,13 +29,8 @@
|
|||||||
#include <isc/ondestroy.h>
|
#include <isc/ondestroy.h>
|
||||||
#include <isc/string.h>
|
#include <isc/string.h>
|
||||||
|
|
||||||
#ifndef ISC_SINGLETHREADED
|
|
||||||
#include <isc/mutex.h>
|
#include <isc/mutex.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
#else
|
|
||||||
#define LOCK(l)
|
|
||||||
#define UNLOCK(l)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
unsigned int isc_mem_debugging = 0;
|
unsigned int isc_mem_debugging = 0;
|
||||||
|
|
||||||
@ -53,7 +48,7 @@ unsigned int isc_mem_debugging = 0;
|
|||||||
/*
|
/*
|
||||||
* Types.
|
* Types.
|
||||||
*/
|
*/
|
||||||
#ifdef ISC_MEM_TRACKLINES
|
#if ISC_MEM_TRACKLINES
|
||||||
typedef struct debuglink debuglink_t;
|
typedef struct debuglink debuglink_t;
|
||||||
struct debuglink {
|
struct debuglink {
|
||||||
ISC_LINK(debuglink_t) link;
|
ISC_LINK(debuglink_t) link;
|
||||||
@ -124,7 +119,7 @@ struct isc_mem {
|
|||||||
isc_mem_water_t water;
|
isc_mem_water_t water;
|
||||||
void * water_arg;
|
void * water_arg;
|
||||||
ISC_LIST(isc_mempool_t) pools;
|
ISC_LIST(isc_mempool_t) pools;
|
||||||
#ifdef ISC_MEM_TRACKLINES
|
#if ISC_MEM_TRACKLINES
|
||||||
ISC_LIST(debuglink_t) debuglist;
|
ISC_LIST(debuglink_t) debuglist;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -150,7 +145,7 @@ struct isc_mempool {
|
|||||||
/* Stats only. */
|
/* Stats only. */
|
||||||
unsigned int gets; /* # of requests to this pool */
|
unsigned int gets; /* # of requests to this pool */
|
||||||
/* Debugging only. */
|
/* Debugging only. */
|
||||||
#ifdef ISC_MEMPOOL_NAMES
|
#if ISC_MEMPOOL_NAMES
|
||||||
char name[16]; /* printed name in stats reports */
|
char name[16]; /* printed name in stats reports */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -159,7 +154,7 @@ struct isc_mempool {
|
|||||||
* Private Inline-able.
|
* Private Inline-able.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ISC_MEM_TRACKLINES
|
#if ! ISC_MEM_TRACKLINES
|
||||||
#define ADD_TRACE(a, b, c, d, e)
|
#define ADD_TRACE(a, b, c, d, e)
|
||||||
#define DELETE_TRACE(a, b, c, d, e)
|
#define DELETE_TRACE(a, b, c, d, e)
|
||||||
#else
|
#else
|
||||||
@ -542,7 +537,7 @@ mem_getunlocked(isc_mem_t *ctx, size_t size) {
|
|||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
#ifdef ISC_MEM_FILL
|
#if ISC_MEM_FILL
|
||||||
if (ret != NULL)
|
if (ret != NULL)
|
||||||
memset(ret, 0xbe, new_size); /* Mnemonic for "beef". */
|
memset(ret, 0xbe, new_size); /* Mnemonic for "beef". */
|
||||||
#endif
|
#endif
|
||||||
@ -558,7 +553,7 @@ mem_putunlocked(isc_mem_t *ctx, void *mem, size_t size) {
|
|||||||
/*
|
/*
|
||||||
* memput() called on something beyond our upper limit.
|
* memput() called on something beyond our upper limit.
|
||||||
*/
|
*/
|
||||||
#ifdef ISC_MEM_FILL
|
#if ISC_MEM_FILL
|
||||||
memset(mem, 0xde, size); /* Mnemonic for "dead". */
|
memset(mem, 0xde, size); /* Mnemonic for "dead". */
|
||||||
#endif
|
#endif
|
||||||
(ctx->memfree)(ctx->arg, mem);
|
(ctx->memfree)(ctx->arg, mem);
|
||||||
@ -570,8 +565,8 @@ mem_putunlocked(isc_mem_t *ctx, void *mem, size_t size) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ISC_MEM_FILL
|
#if ISC_MEM_FILL
|
||||||
#ifdef ISC_MEM_CHECKOVERRUN
|
#if ISC_MEM_CHECKOVERRUN
|
||||||
check_overrun(mem, size, new_size);
|
check_overrun(mem, size, new_size);
|
||||||
#endif
|
#endif
|
||||||
memset(mem, 0xde, new_size); /* Mnemonic for "dead". */
|
memset(mem, 0xde, new_size); /* Mnemonic for "dead". */
|
||||||
@ -874,7 +869,7 @@ isc_mem_restore(isc_mem_t *ctx) {
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ISC_MEM_FILL) && defined(ISC_MEM_CHECKOVERRUN)
|
#if ISC_MEM_FILL && ISC_MEM_CHECKOVERRUN
|
||||||
static inline void
|
static inline void
|
||||||
check_overrun(void *mem, size_t size, size_t new_size) {
|
check_overrun(void *mem, size_t size, size_t new_size) {
|
||||||
unsigned char *cp;
|
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->freemax = 1;
|
||||||
mpctx->fillcount = 1;
|
mpctx->fillcount = 1;
|
||||||
mpctx->gets = 0;
|
mpctx->gets = 0;
|
||||||
#ifdef ISC_MEMPOOL_NAMES
|
#if ISC_MEMPOOL_NAMES
|
||||||
mpctx->name[0] = 0;
|
mpctx->name[0] = 0;
|
||||||
#endif
|
#endif
|
||||||
mpctx->items = NULL;
|
mpctx->items = NULL;
|
||||||
@ -1346,7 +1341,7 @@ void
|
|||||||
isc_mempool_setname(isc_mempool_t *mpctx, const char *name) {
|
isc_mempool_setname(isc_mempool_t *mpctx, const char *name) {
|
||||||
REQUIRE(name != NULL);
|
REQUIRE(name != NULL);
|
||||||
|
|
||||||
#ifdef ISC_MEMPOOL_NAMES
|
#if ISC_MEMPOOL_NAMES
|
||||||
if (mpctx->lock != NULL)
|
if (mpctx->lock != NULL)
|
||||||
LOCK(mpctx->lock);
|
LOCK(mpctx->lock);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user