2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Replace custom isc_boolean_t with C standard bool type

This commit is contained in:
Ondřej Surý
2018-04-17 08:29:14 -07:00
parent cb6a185c69
commit 994e656977
546 changed files with 10785 additions and 10367 deletions

View File

@@ -14,6 +14,7 @@
#include <config.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@@ -125,7 +126,7 @@ struct isc__mem {
isc_memfree_t memfree;
void * arg;
size_t max_size;
isc_boolean_t checkfree;
bool checkfree;
struct stats * stats;
unsigned int references;
char name[16];
@@ -138,8 +139,8 @@ struct isc__mem {
size_t maxmalloced;
size_t hi_water;
size_t lo_water;
isc_boolean_t hi_called;
isc_boolean_t is_overmem;
bool hi_called;
bool is_overmem;
isc_mem_water_t water;
void * water_arg;
ISC_LIST(isc__mempool_t) pools;
@@ -250,7 +251,7 @@ isc___mem_free(isc_mem_t *ctx, void *ptr FLARG);
char *
isc___mem_strdup(isc_mem_t *mctx, const char *s FLARG);
void
isc__mem_setdestroycheck(isc_mem_t *ctx, isc_boolean_t flag);
isc__mem_setdestroycheck(isc_mem_t *ctx, bool flag);
void
isc__mem_setquota(isc_mem_t *ctx, size_t quota);
size_t
@@ -261,7 +262,7 @@ size_t
isc__mem_maxinuse(isc_mem_t *ctx);
size_t
isc__mem_total(isc_mem_t *ctx);
isc_boolean_t
bool
isc__mem_isovermem(isc_mem_t *ctx);
void
isc__mem_setwater(isc_mem_t *ctx, isc_mem_water_t water, void *water_arg,
@@ -392,7 +393,7 @@ add_trace_entry(isc__mem_t *mctx, const void *ptr, size_t size FLARG) {
if (mctx->debuglist == NULL)
return;
hash = isc_hash_function(&ptr, sizeof(ptr), ISC_TRUE, NULL);
hash = isc_hash_function(&ptr, sizeof(ptr), true, NULL);
idx = hash % DEBUG_TABLE_COUNT;
dl = malloc(sizeof(debuglink_t));
@@ -429,7 +430,7 @@ delete_trace_entry(isc__mem_t *mctx, const void *ptr, size_t size,
if (mctx->debuglist == NULL)
return;
hash = isc_hash_function(&ptr, sizeof(ptr), ISC_TRUE, NULL);
hash = isc_hash_function(&ptr, sizeof(ptr), true, NULL);
idx = hash % DEBUG_TABLE_COUNT;
dl = ISC_LIST_HEAD(mctx->debuglist[idx]);
@@ -472,7 +473,7 @@ quantize(size_t size) {
return ((size + ALIGNMENT_SIZE - 1) & (~(ALIGNMENT_SIZE - 1)));
}
static inline isc_boolean_t
static inline bool
more_basic_blocks(isc__mem_t *ctx) {
void *tmp;
unsigned char *curr, *next;
@@ -489,7 +490,7 @@ more_basic_blocks(isc__mem_t *ctx) {
*/
increment = NUM_BASIC_BLOCKS * ctx->mem_target;
if (ctx->quota != 0U && ctx->total + increment > ctx->quota)
return (ISC_FALSE);
return (false);
INSIST(ctx->basic_table_count <= ctx->basic_table_size);
if (ctx->basic_table_count == ctx->basic_table_size) {
@@ -498,7 +499,7 @@ more_basic_blocks(isc__mem_t *ctx) {
table_size * sizeof(unsigned char *));
if (table == NULL) {
ctx->memalloc_failures++;
return (ISC_FALSE);
return (false);
}
ctx->malloced += table_size * sizeof(unsigned char *);
if (ctx->malloced > ctx->maxmalloced)
@@ -518,7 +519,7 @@ more_basic_blocks(isc__mem_t *ctx) {
tmp = (ctx->memalloc)(ctx->arg, NUM_BASIC_BLOCKS * ctx->mem_target);
if (tmp == NULL) {
ctx->memalloc_failures++;
return (ISC_FALSE);
return (false);
}
ctx->total += increment;
ctx->basic_table[ctx->basic_table_count] = tmp;
@@ -547,10 +548,10 @@ more_basic_blocks(isc__mem_t *ctx) {
ctx->highest = last;
ctx->basic_blocks = tmp;
return (ISC_TRUE);
return (true);
}
static inline isc_boolean_t
static inline bool
more_frags(isc__mem_t *ctx, size_t new_size) {
int i, frags;
size_t total_size;
@@ -570,7 +571,7 @@ more_frags(isc__mem_t *ctx, size_t new_size) {
/*
* XXXRTH "At quota" notification here.
*/
return (ISC_FALSE);
return (false);
}
}
@@ -609,7 +610,7 @@ more_frags(isc__mem_t *ctx, size_t new_size) {
((element *)curr)->next = NULL;
ctx->freelists[new_size] = tmp;
return (ISC_TRUE);
return (true);
}
static inline void *
@@ -915,8 +916,8 @@ isc_mem_createx2(size_t init_max_size, size_t target_size,
ctx->maxmalloced = sizeof(*ctx);
ctx->hi_water = 0;
ctx->lo_water = 0;
ctx->hi_called = ISC_FALSE;
ctx->is_overmem = ISC_FALSE;
ctx->hi_called = false;
ctx->is_overmem = false;
ctx->water = NULL;
ctx->water_arg = NULL;
ctx->common.impmagic = MEM_MAGIC;
@@ -926,7 +927,7 @@ isc_mem_createx2(size_t init_max_size, size_t target_size,
ctx->memfree = memfree;
ctx->arg = arg;
ctx->stats = NULL;
ctx->checkfree = ISC_TRUE;
ctx->checkfree = true;
#if ISC_MEM_TRACKLINES
ctx->debuglist = NULL;
ctx->debuglistcnt = 0;
@@ -1107,7 +1108,7 @@ isc__mem_attach(isc_mem_t *source0, isc_mem_t **targetp) {
void
isc__mem_detach(isc_mem_t **ctxp) {
isc__mem_t *ctx;
isc_boolean_t want_destroy = ISC_FALSE;
bool want_destroy = false;
REQUIRE(ctxp != NULL);
ctx = (isc__mem_t *)*ctxp;
@@ -1117,7 +1118,7 @@ isc__mem_detach(isc_mem_t **ctxp) {
INSIST(ctx->references > 0);
ctx->references--;
if (ctx->references == 0)
want_destroy = ISC_TRUE;
want_destroy = true;
MCTXUNLOCK(ctx, &ctx->lock);
if (want_destroy)
@@ -1139,7 +1140,7 @@ isc__mem_detach(isc_mem_t **ctxp) {
void
isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG) {
isc__mem_t *ctx;
isc_boolean_t want_destroy = ISC_FALSE;
bool want_destroy = false;
size_info *si;
size_t oldsize;
@@ -1169,7 +1170,7 @@ isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG) {
MCTXLOCK(ctx, &ctx->lock);
ctx->references--;
if (ctx->references == 0)
want_destroy = ISC_TRUE;
want_destroy = true;
MCTXUNLOCK(ctx, &ctx->lock);
if (want_destroy)
destroy(ctx);
@@ -1191,7 +1192,7 @@ isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG) {
INSIST(ctx->references > 0);
ctx->references--;
if (ctx->references == 0)
want_destroy = ISC_TRUE;
want_destroy = true;
MCTXUNLOCK(ctx, &ctx->lock);
@@ -1230,7 +1231,7 @@ void *
isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
void *ptr;
isc_boolean_t call_water = ISC_FALSE;
bool call_water = false;
REQUIRE(VALID_CONTEXT(ctx));
@@ -1251,9 +1252,9 @@ isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
ADD_TRACE(ctx, ptr, size, file, line);
if (ctx->hi_water != 0U && ctx->inuse > ctx->hi_water) {
ctx->is_overmem = ISC_TRUE;
ctx->is_overmem = true;
if (!ctx->hi_called)
call_water = ISC_TRUE;
call_water = true;
}
if (ctx->inuse > ctx->maxinuse) {
ctx->maxinuse = ctx->inuse;
@@ -1273,7 +1274,7 @@ 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) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
isc_boolean_t call_water = ISC_FALSE;
bool call_water = false;
size_info *si;
size_t oldsize;
@@ -1311,9 +1312,9 @@ isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
* isc_mem_setwater() called with 0 for hi_water and lo_water.
*/
if ((ctx->inuse < ctx->lo_water) || (ctx->lo_water == 0U)) {
ctx->is_overmem = ISC_FALSE;
ctx->is_overmem = false;
if (ctx->hi_called)
call_water = ISC_TRUE;
call_water = true;
}
MCTXUNLOCK(ctx, &ctx->lock);
@@ -1330,9 +1331,9 @@ isc__mem_waterack(isc_mem_t *ctx0, int flag) {
MCTXLOCK(ctx, &ctx->lock);
if (flag == ISC_MEM_LOWATER)
ctx->hi_called = ISC_FALSE;
ctx->hi_called = false;
else if (flag == ISC_MEM_HIWATER)
ctx->hi_called = ISC_TRUE;
ctx->hi_called = true;
MCTXUNLOCK(ctx, &ctx->lock);
}
@@ -1343,13 +1344,13 @@ print_active(isc__mem_t *mctx, FILE *out) {
debuglink_t *dl;
unsigned int i;
const char *format;
isc_boolean_t found;
bool found;
fprintf(out, "%s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
ISC_MSG_DUMPALLOC,
"Dump of all outstanding "
"memory allocations:\n"));
found = ISC_FALSE;
found = false;
format = isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
ISC_MSG_PTRFILELINE,
"\tptr %p size %u file %s line %u\n");
@@ -1357,7 +1358,7 @@ print_active(isc__mem_t *mctx, FILE *out) {
dl = ISC_LIST_HEAD(mctx->debuglist[i]);
if (dl != NULL)
found = ISC_TRUE;
found = true;
while (dl != NULL) {
if (dl->ptr != NULL)
@@ -1488,7 +1489,7 @@ void *
isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_info *si;
isc_boolean_t call_water = ISC_FALSE;
bool call_water = false;
REQUIRE(VALID_CONTEXT(ctx));
@@ -1500,13 +1501,13 @@ isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
ADD_TRACE(ctx, si, si[-1].u.size, file, line);
if (ctx->hi_water != 0U && ctx->inuse > ctx->hi_water &&
!ctx->is_overmem) {
ctx->is_overmem = ISC_TRUE;
ctx->is_overmem = true;
}
if (ctx->hi_water != 0U && !ctx->hi_called &&
ctx->inuse > ctx->hi_water) {
ctx->hi_called = ISC_TRUE;
call_water = ISC_TRUE;
ctx->hi_called = true;
call_water = true;
}
if (ctx->inuse > ctx->maxinuse) {
ctx->maxinuse = ctx->inuse;
@@ -1570,7 +1571,7 @@ isc___mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_info *si;
size_t size;
isc_boolean_t call_water= ISC_FALSE;
bool call_water= false;
REQUIRE(VALID_CONTEXT(ctx));
REQUIRE(ptr != NULL);
@@ -1602,15 +1603,15 @@ isc___mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
*/
if (ctx->is_overmem &&
(ctx->inuse < ctx->lo_water || ctx->lo_water == 0U)) {
ctx->is_overmem = ISC_FALSE;
ctx->is_overmem = false;
}
if (ctx->hi_called &&
(ctx->inuse < ctx->lo_water || ctx->lo_water == 0U)) {
ctx->hi_called = ISC_FALSE;
ctx->hi_called = false;
if (ctx->water != NULL)
call_water = ISC_TRUE;
call_water = true;
}
MCTXUNLOCK(ctx, &ctx->lock);
@@ -1643,7 +1644,7 @@ isc___mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
}
void
isc__mem_setdestroycheck(isc_mem_t *ctx0, isc_boolean_t flag) {
isc__mem_setdestroycheck(isc_mem_t *ctx0, bool flag) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
@@ -1735,7 +1736,7 @@ isc__mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
size_t hiwater, size_t lowater)
{
isc__mem_t *ctx = (isc__mem_t *)ctx0;
isc_boolean_t callwater = ISC_FALSE;
bool callwater = false;
isc_mem_water_t oldwater;
void *oldwater_arg;
@@ -1755,7 +1756,7 @@ isc__mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
if (ctx->hi_called &&
(ctx->water != water || ctx->water_arg != water_arg ||
ctx->inuse < lowater || lowater == 0U))
callwater = ISC_TRUE;
callwater = true;
ctx->water = water;
ctx->water_arg = water_arg;
ctx->hi_water = hiwater;
@@ -1767,7 +1768,7 @@ isc__mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
(oldwater)(oldwater_arg, ISC_MEM_LOWATER);
}
isc_boolean_t
bool
isc__mem_isovermem(isc_mem_t *ctx0) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
@@ -2788,7 +2789,7 @@ isc_mem_destroy(isc_mem_t **mctxp) {
}
void
isc_mem_setdestroycheck(isc_mem_t *mctx, isc_boolean_t flag) {
isc_mem_setdestroycheck(isc_mem_t *mctx, bool flag) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
mctx->methods->setdestroycheck(mctx, flag);
@@ -2846,7 +2847,7 @@ isc_mem_total(isc_mem_t *mctx) {
return (mctx->methods->total(mctx));
}
isc_boolean_t
bool
isc_mem_isovermem(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));