mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Make the DbC checks to be consistent and cppcheck clean
This commit is contained in:
parent
bb65e57297
commit
478e4ac201
187
lib/isc/mem.c
187
lib/isc/mem.c
@ -363,7 +363,6 @@ more_basic_blocks(isc__mem_t *ctx) {
|
||||
if (ctx->basic_table_count == ctx->basic_table_size) {
|
||||
table_size = ctx->basic_table_size + TABLE_INCREMENT;
|
||||
table = (ctx->memalloc)(table_size * sizeof(unsigned char *));
|
||||
RUNTIME_CHECK(table != NULL);
|
||||
ctx->malloced += table_size * sizeof(unsigned char *);
|
||||
if (ctx->malloced > ctx->maxmalloced)
|
||||
ctx->maxmalloced = ctx->malloced;
|
||||
@ -380,7 +379,6 @@ more_basic_blocks(isc__mem_t *ctx) {
|
||||
}
|
||||
|
||||
tmp = (ctx->memalloc)(NUM_BASIC_BLOCKS * ctx->mem_target);
|
||||
RUNTIME_CHECK(tmp != NULL);
|
||||
ctx->total += NUM_BASIC_BLOCKS * ctx->mem_target;;
|
||||
ctx->basic_table[ctx->basic_table_count] = tmp;
|
||||
ctx->basic_table_count++;
|
||||
@ -473,7 +471,6 @@ mem_getunlocked(isc__mem_t *ctx, size_t size) {
|
||||
* memget() was called on something beyond our upper limit.
|
||||
*/
|
||||
ret = (ctx->memalloc)(size);
|
||||
RUNTIME_CHECK(ret != NULL);
|
||||
ctx->total += size;
|
||||
ctx->inuse += size;
|
||||
ctx->stats[ctx->max_size].gets++;
|
||||
@ -596,7 +593,6 @@ mem_get(isc__mem_t *ctx, size_t size) {
|
||||
size += 1;
|
||||
#endif
|
||||
ret = (ctx->memalloc)(size);
|
||||
RUNTIME_CHECK(ret != NULL);
|
||||
|
||||
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) {
|
||||
if (ISC_LIKELY(ret != NULL))
|
||||
@ -723,10 +719,10 @@ initialize_action(void) {
|
||||
static void
|
||||
mem_create(isc_mem_t **ctxp, unsigned int flags)
|
||||
{
|
||||
isc__mem_t *ctx;
|
||||
|
||||
REQUIRE(ctxp != NULL && *ctxp == NULL);
|
||||
|
||||
isc__mem_t *ctx;
|
||||
|
||||
STATIC_ASSERT((ALIGNMENT_SIZE & (ALIGNMENT_SIZE - 1)) == 0,
|
||||
"wrong alignment size");
|
||||
|
||||
@ -774,7 +770,6 @@ mem_create(isc_mem_t **ctxp, unsigned int flags)
|
||||
ctx->highest = NULL;
|
||||
|
||||
ctx->stats = (ctx->memalloc)((ctx->max_size+1) * sizeof(struct stats));
|
||||
RUNTIME_CHECK(ctx->stats != NULL);
|
||||
|
||||
memset(ctx->stats, 0, (ctx->max_size + 1) * sizeof(struct stats));
|
||||
ctx->malloced += (ctx->max_size+1) * sizeof(struct stats);
|
||||
@ -784,7 +779,6 @@ mem_create(isc_mem_t **ctxp, unsigned int flags)
|
||||
ctx->mem_target = DEF_MEM_TARGET;
|
||||
ctx->freelists = (ctx->memalloc)(ctx->max_size *
|
||||
sizeof(element *));
|
||||
RUNTIME_CHECK(ctx->freelists != NULL);
|
||||
memset(ctx->freelists, 0,
|
||||
ctx->max_size * sizeof(element *));
|
||||
ctx->malloced += ctx->max_size * sizeof(element *);
|
||||
@ -797,7 +791,6 @@ mem_create(isc_mem_t **ctxp, unsigned int flags)
|
||||
|
||||
ctx->debuglist = (ctx->memalloc)((DEBUG_TABLE_COUNT *
|
||||
sizeof(debuglist_t)));
|
||||
RUNTIME_CHECK(ctx->debuglist != NULL);
|
||||
for (i = 0; i < DEBUG_TABLE_COUNT; i++)
|
||||
ISC_LIST_INIT(ctx->debuglist[i]);
|
||||
ctx->malloced += DEBUG_TABLE_COUNT * sizeof(debuglist_t);
|
||||
@ -895,11 +888,11 @@ destroy(isc__mem_t *ctx) {
|
||||
|
||||
void
|
||||
isc_mem_attach(isc_mem_t *source0, isc_mem_t **targetp) {
|
||||
isc__mem_t *source = (isc__mem_t *)source0;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(source));
|
||||
REQUIRE(VALID_CONTEXT(source0));
|
||||
REQUIRE(targetp != NULL && *targetp == NULL);
|
||||
|
||||
isc__mem_t *source = (isc__mem_t *)source0;
|
||||
|
||||
isc_refcount_increment(&source->references);
|
||||
|
||||
*targetp = (isc_mem_t *)source;
|
||||
@ -908,6 +901,7 @@ isc_mem_attach(isc_mem_t *source0, isc_mem_t **targetp) {
|
||||
void
|
||||
isc_mem_detach(isc_mem_t **ctxp) {
|
||||
REQUIRE(ctxp != NULL && VALID_CONTEXT(*ctxp));
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)*ctxp;
|
||||
*ctxp = NULL;
|
||||
|
||||
@ -931,6 +925,7 @@ void
|
||||
isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG) {
|
||||
REQUIRE(ctxp != NULL && VALID_CONTEXT(*ctxp));
|
||||
REQUIRE(ptr != NULL);
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)*ctxp;
|
||||
*ctxp = NULL;
|
||||
|
||||
@ -970,16 +965,14 @@ destroy:
|
||||
|
||||
void
|
||||
isc_mem_destroy(isc_mem_t **ctxp) {
|
||||
isc__mem_t *ctx;
|
||||
|
||||
/*
|
||||
* This routine provides legacy support for callers who use mctxs
|
||||
* without attaching/detaching.
|
||||
*/
|
||||
|
||||
REQUIRE(ctxp != NULL);
|
||||
ctx = (isc__mem_t *)*ctxp;
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
REQUIRE(ctxp != NULL && VALID_CONTEXT(*ctxp));
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)*ctxp;
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (isc_refcount_decrement(&ctx->references) > 1) {
|
||||
@ -996,12 +989,12 @@ isc_mem_destroy(isc_mem_t **ctxp) {
|
||||
|
||||
void *
|
||||
isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
void *ptr;
|
||||
bool call_water = false;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
|
||||
if (ISC_UNLIKELY((isc_mem_debugging &
|
||||
(ISC_MEM_DEBUGSIZE|ISC_MEM_DEBUGCTX)) != 0))
|
||||
return (isc__mem_allocate(ctx0, size FLARG_PASS));
|
||||
@ -1040,14 +1033,14 @@ isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
|
||||
|
||||
void
|
||||
isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
REQUIRE(ptr != NULL);
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
bool call_water = false;
|
||||
size_info *si;
|
||||
size_t oldsize;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
REQUIRE(ptr != NULL);
|
||||
|
||||
if (ISC_UNLIKELY((isc_mem_debugging &
|
||||
(ISC_MEM_DEBUGSIZE|ISC_MEM_DEBUGCTX)) != 0))
|
||||
{
|
||||
@ -1092,9 +1085,9 @@ isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
|
||||
|
||||
void
|
||||
isc_mem_waterack(isc_mem_t *ctx0, int flag) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
MCTXLOCK(ctx);
|
||||
if (flag == ISC_MEM_LOWATER)
|
||||
@ -1144,12 +1137,13 @@ print_active(isc__mem_t *mctx, FILE *out) {
|
||||
*/
|
||||
void
|
||||
isc_mem_stats(isc_mem_t *ctx0, FILE *out) {
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
size_t i;
|
||||
const struct stats *s;
|
||||
const isc__mempool_t *pool;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
MCTXLOCK(ctx);
|
||||
|
||||
for (i = 0; i <= ctx->max_size; i++) {
|
||||
@ -1232,12 +1226,12 @@ mem_allocateunlocked(isc_mem_t *ctx0, size_t size) {
|
||||
|
||||
void *
|
||||
isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
size_info *si;
|
||||
bool call_water = false;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
|
||||
MCTXLOCK(ctx);
|
||||
si = mem_allocateunlocked((isc_mem_t *)ctx, size);
|
||||
if (((ctx->flags & ISC_MEMFLAG_INTERNAL) == 0)) {
|
||||
@ -1274,12 +1268,11 @@ isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
|
||||
|
||||
void *
|
||||
isc___mem_reallocate(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
void *new_ptr = NULL;
|
||||
size_t oldsize, copysize;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
|
||||
/*
|
||||
* This function emulates the realloc(3) standard library function:
|
||||
* - if size > 0, allocate new memory; and if ptr is non NULL, copy
|
||||
@ -1315,14 +1308,14 @@ isc___mem_reallocate(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
|
||||
|
||||
void
|
||||
isc___mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
REQUIRE(ptr != NULL);
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
size_info *si;
|
||||
size_t size;
|
||||
bool call_water= false;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
REQUIRE(ptr != NULL);
|
||||
|
||||
if (ISC_UNLIKELY((isc_mem_debugging & ISC_MEM_DEBUGCTX) != 0)) {
|
||||
si = &(((size_info *)ptr)[-2]);
|
||||
REQUIRE(si->u.ctx == ctx);
|
||||
@ -1373,13 +1366,13 @@ isc___mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
|
||||
|
||||
char *
|
||||
isc___mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
|
||||
REQUIRE(VALID_CONTEXT(mctx0));
|
||||
REQUIRE(s != NULL);
|
||||
|
||||
isc__mem_t *mctx = (isc__mem_t *)mctx0;
|
||||
size_t len;
|
||||
char *ns;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(mctx));
|
||||
REQUIRE(s != NULL);
|
||||
|
||||
len = strlen(s) + 1;
|
||||
|
||||
ns = isc__mem_allocate((isc_mem_t *)mctx, len FLARG_PASS);
|
||||
@ -1392,9 +1385,10 @@ isc___mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
|
||||
|
||||
void
|
||||
isc_mem_setdestroycheck(isc_mem_t *ctx0, bool flag) {
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
MCTXLOCK(ctx);
|
||||
|
||||
ctx->checkfree = flag;
|
||||
@ -1404,10 +1398,11 @@ isc_mem_setdestroycheck(isc_mem_t *ctx0, bool flag) {
|
||||
|
||||
size_t
|
||||
isc_mem_inuse(isc_mem_t *ctx0) {
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
size_t inuse;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
MCTXLOCK(ctx);
|
||||
|
||||
inuse = ctx->inuse;
|
||||
@ -1419,10 +1414,11 @@ isc_mem_inuse(isc_mem_t *ctx0) {
|
||||
|
||||
size_t
|
||||
isc_mem_maxinuse(isc_mem_t *ctx0) {
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
size_t maxinuse;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
MCTXLOCK(ctx);
|
||||
|
||||
maxinuse = ctx->maxinuse;
|
||||
@ -1434,10 +1430,11 @@ isc_mem_maxinuse(isc_mem_t *ctx0) {
|
||||
|
||||
size_t
|
||||
isc_mem_total(isc_mem_t *ctx0) {
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
size_t total;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
MCTXLOCK(ctx);
|
||||
|
||||
total = ctx->total;
|
||||
@ -1451,14 +1448,14 @@ void
|
||||
isc_mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
|
||||
size_t hiwater, size_t lowater)
|
||||
{
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
REQUIRE(hiwater >= lowater);
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
bool callwater = false;
|
||||
isc_mem_water_t oldwater;
|
||||
void *oldwater_arg;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
REQUIRE(hiwater >= lowater);
|
||||
|
||||
MCTXLOCK(ctx);
|
||||
oldwater = ctx->water;
|
||||
oldwater_arg = ctx->water_arg;
|
||||
@ -1486,9 +1483,9 @@ isc_mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
|
||||
|
||||
bool
|
||||
isc_mem_isovermem(isc_mem_t *ctx0) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
/*
|
||||
* We don't bother to lock the context because 100% accuracy isn't
|
||||
@ -1500,9 +1497,9 @@ isc_mem_isovermem(isc_mem_t *ctx0) {
|
||||
|
||||
void
|
||||
isc_mem_setname(isc_mem_t *ctx0, const char *name, void *tag) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
LOCK(&ctx->lock);
|
||||
strlcpy(ctx->name, name, sizeof(ctx->name));
|
||||
@ -1512,9 +1509,9 @@ isc_mem_setname(isc_mem_t *ctx0, const char *name, void *tag) {
|
||||
|
||||
const char *
|
||||
isc_mem_getname(isc_mem_t *ctx0) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
if (ctx->name[0] == 0)
|
||||
return ("");
|
||||
@ -1524,9 +1521,9 @@ isc_mem_getname(isc_mem_t *ctx0) {
|
||||
|
||||
void *
|
||||
isc_mem_gettag(isc_mem_t *ctx0) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
return (ctx->tag);
|
||||
}
|
||||
@ -1537,19 +1534,18 @@ isc_mem_gettag(isc_mem_t *ctx0) {
|
||||
|
||||
void
|
||||
isc_mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
|
||||
isc__mem_t *mctx = (isc__mem_t *)mctx0;
|
||||
isc__mempool_t *mpctx;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(mctx));
|
||||
REQUIRE(VALID_CONTEXT(mctx0));
|
||||
REQUIRE(size > 0U);
|
||||
REQUIRE(mpctxp != NULL && *mpctxp == NULL);
|
||||
|
||||
isc__mem_t *mctx = (isc__mem_t *)mctx0;
|
||||
isc__mempool_t *mpctx;
|
||||
|
||||
/*
|
||||
* Allocate space for this pool, initialize values, and if all works
|
||||
* well, attach to the memory context.
|
||||
*/
|
||||
mpctx = isc_mem_get((isc_mem_t *)mctx, sizeof(isc__mempool_t));
|
||||
RUNTIME_CHECK(mpctx != NULL);
|
||||
|
||||
mpctx->common.impmagic = MEMPOOL_MAGIC;
|
||||
mpctx->common.magic = ISCAPI_MPOOL_MAGIC;
|
||||
@ -1583,10 +1579,10 @@ isc_mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
|
||||
|
||||
void
|
||||
isc_mempool_setname(isc_mempool_t *mpctx0, const char *name) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
REQUIRE(name != NULL);
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
#if ISC_MEMPOOL_NAMES
|
||||
if (mpctx->lock != NULL)
|
||||
@ -1604,14 +1600,15 @@ isc_mempool_setname(isc_mempool_t *mpctx0, const char *name) {
|
||||
|
||||
void
|
||||
isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
||||
REQUIRE(mpctxp != NULL);
|
||||
REQUIRE(VALID_MEMPOOL(*mpctxp));
|
||||
|
||||
isc__mempool_t *mpctx;
|
||||
isc__mem_t *mctx;
|
||||
isc_mutex_t *lock;
|
||||
element *item;
|
||||
|
||||
REQUIRE(mpctxp != NULL);
|
||||
mpctx = (isc__mempool_t *)*mpctxp;
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
#if ISC_MEMPOOL_NAMES
|
||||
if (mpctx->allocated > 0)
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
@ -1668,24 +1665,25 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
||||
|
||||
void
|
||||
isc_mempool_associatelock(isc_mempool_t *mpctx0, isc_mutex_t *lock) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
REQUIRE(lock != NULL);
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
REQUIRE(mpctx->lock == NULL);
|
||||
REQUIRE(lock != NULL);
|
||||
|
||||
mpctx->lock = lock;
|
||||
}
|
||||
|
||||
void *
|
||||
isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
element *item;
|
||||
isc__mem_t *mctx;
|
||||
unsigned int i;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
|
||||
mctx = mpctx->mctx;
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
@ -1755,14 +1753,12 @@ isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
|
||||
/* coverity[+free : arg-1] */
|
||||
void
|
||||
isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
isc__mem_t *mctx;
|
||||
element *item;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
REQUIRE(mem != NULL);
|
||||
|
||||
mctx = mpctx->mctx;
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
isc__mem_t *mctx = mpctx->mctx;
|
||||
element *item;
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
@ -1813,9 +1809,9 @@ isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
|
||||
|
||||
void
|
||||
isc_mempool_setfreemax(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
@ -1828,11 +1824,11 @@ isc_mempool_setfreemax(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getfreemax(isc_mempool_t *mpctx0) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
unsigned int freemax;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
|
||||
@ -1846,10 +1842,11 @@ isc_mempool_getfreemax(isc_mempool_t *mpctx0) {
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getfreecount(isc_mempool_t *mpctx0) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
unsigned int freecount;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
@ -1864,11 +1861,10 @@ isc_mempool_getfreecount(isc_mempool_t *mpctx0) {
|
||||
|
||||
void
|
||||
isc_mempool_setmaxalloc(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
REQUIRE(limit > 0);
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
@ -1881,11 +1877,11 @@ isc_mempool_setmaxalloc(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getmaxalloc(isc_mempool_t *mpctx0) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
unsigned int maxalloc;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
|
||||
@ -1899,10 +1895,11 @@ isc_mempool_getmaxalloc(isc_mempool_t *mpctx0) {
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getallocated(isc_mempool_t *mpctx0) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
unsigned int allocated;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
@ -1917,10 +1914,10 @@ isc_mempool_getallocated(isc_mempool_t *mpctx0) {
|
||||
|
||||
void
|
||||
isc_mempool_setfillcount(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
REQUIRE(limit > 0);
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
@ -1933,12 +1930,12 @@ isc_mempool_setfillcount(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getfillcount(isc_mempool_t *mpctx0) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
unsigned int fillcount;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
|
||||
@ -2011,10 +2008,10 @@ static int
|
||||
xml_renderctx(isc__mem_t *ctx, summarystat_t *summary,
|
||||
xmlTextWriterPtr writer)
|
||||
{
|
||||
int xmlrc;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
|
||||
int xmlrc;
|
||||
|
||||
MCTXLOCK(ctx);
|
||||
|
||||
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "context"));
|
||||
@ -2196,13 +2193,13 @@ isc_mem_renderxml(void *writer0) {
|
||||
|
||||
static isc_result_t
|
||||
json_renderctx(isc__mem_t *ctx, summarystat_t *summary, json_object *array) {
|
||||
json_object *ctxobj, *obj;
|
||||
char buf[1024];
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
REQUIRE(summary != NULL);
|
||||
REQUIRE(array != NULL);
|
||||
|
||||
json_object *ctxobj, *obj;
|
||||
char buf[1024];
|
||||
|
||||
MCTXLOCK(ctx);
|
||||
|
||||
summary->contextsize += sizeof(*ctx) +
|
||||
@ -2409,11 +2406,11 @@ isc__mem_free(isc_mem_t *mctx, void *ptr FLARG) {
|
||||
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(VALID_CONTEXT(ctx0));
|
||||
REQUIRE(file != NULL);
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
print_active(ctx, file);
|
||||
#else
|
||||
UNUSED(ctx0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user