2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 18:19:42 +00:00

chg: dev: Set name for all the isc_mem context from isc_mem_create()

Instead of giving the memory context names with an explicit call to
isc_mem_setname(), add the name to isc_mem_create() call to have all the
memory contexts an unconditional name.

Merge branch 'ondrej/ondrej-isc_mem_create-with-name' into 'main'

See merge request isc-projects/bind9!10426
This commit is contained in:
Ondřej Surý 2025-05-29 03:50:44 +00:00
commit ccf7a7dd7e
57 changed files with 96 additions and 144 deletions

View File

@ -108,7 +108,7 @@ add(char *key, int value) {
isc_symvalue_t symvalue;
if (sym_mctx == NULL) {
isc_mem_create(&sym_mctx);
isc_mem_create("check-tool", &sym_mctx);
}
if (symtab == NULL) {

View File

@ -619,7 +619,7 @@ main(int argc, char **argv) {
}
isc_commandline_reset = true;
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != EOF) {
switch (c) {

View File

@ -535,7 +535,7 @@ main(int argc, char **argv) {
usage();
}
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
if (!quiet) {
RUNTIME_CHECK(setup_logging(errout) == ISC_R_SUCCESS);
}

View File

@ -108,6 +108,7 @@ main(int argc, char **argv) {
bool keyonly = false;
bool quiet = false;
int len;
const char *name = argv[0];
keydef = keyfile = RNDC_KEYFILE;
@ -226,7 +227,7 @@ main(int argc, char **argv) {
}
algname = dst_hmac_algorithm_totext(alg);
isc_mem_create(&mctx);
isc_mem_create(name, &mctx);
isc_buffer_init(&key_txtbuffer, &key_txtsecret, sizeof(key_txtsecret));
generate_key(mctx, alg, keysize, &key_txtbuffer);

View File

@ -212,7 +212,7 @@ main(int argc, char **argv) {
/* Use canonical algorithm name */
algname = dst_hmac_algorithm_totext(alg);
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
if (keyname == NULL) {
const char *suffix = NULL;

View File

@ -1352,7 +1352,6 @@ setup_libs(void) {
ISC_LOGMODULE_DEFAULT);
isc_log_setdebuglevel(0);
isc_mem_setname(mctx, "dig");
mainloop = isc_loop_main(loopmgr);
}

View File

@ -1080,7 +1080,7 @@ main(int argc, char *argv[]) {
setfatalcallback(cleanup);
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
isc_commandline_errprint = false;

View File

@ -376,7 +376,7 @@ main(int argc, char **argv) {
usage();
}
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
isc_commandline_errprint = false;

View File

@ -308,7 +308,7 @@ main(int argc, char **argv) {
usage();
}
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
isc_commandline_errprint = false;

View File

@ -149,7 +149,7 @@ main(int argc, char **argv) {
usage();
}
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
isc_commandline_errprint = false;

View File

@ -812,7 +812,7 @@ main(int argc, char **argv) {
}
isc_commandline_reset = true;
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
switch (ch) {

View File

@ -1326,7 +1326,7 @@ main(int argc, char *argv[]) {
.now = isc_stdtime_now(),
};
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
isc_commandline_errprint = false;

View File

@ -82,7 +82,7 @@ main(int argc, char **argv) {
usage();
}
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
isc_commandline_errprint = false;

View File

@ -244,7 +244,7 @@ main(int argc, char **argv) {
usage();
}
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
setup_logging();

View File

@ -202,7 +202,7 @@ main(int argc, char *argv[]) {
}
isc_commandline_reset = true;
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
isc_commandline_errprint = false;

View File

@ -222,7 +222,7 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
return ISC_R_FAILURE;
}
isc_mem_create(&mctx);
isc_mem_create("dlz", &mctx);
cd = isc_mem_get(mctx, sizeof(*cd));
*cd = (dlopen_data_t){
.mctx = mctx,

View File

@ -608,7 +608,7 @@ printversion(bool verbose) {
#if defined(HAVE_GEOIP2)
#define RTC(x) RUNTIME_CHECK((x) == ISC_R_SUCCESS)
isc_mem_t *mctx = NULL;
isc_mem_create(&mctx);
isc_mem_create("geoip", &mctx);
RTC(cfg_parser_create(mctx, &parser));
RTC(named_config_parsedefaults(parser, &config));
RTC(cfg_map_get(config, "options", &defaults));
@ -1453,7 +1453,6 @@ main(int argc, char *argv[]) {
}
setup();
isc_mem_setname(named_g_mctx, "main");
INSIST(named_g_server != NULL);
/*

View File

@ -76,7 +76,7 @@ main(int argc, char **argv) {
journal = argv[4];
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
logconfig = isc_logconfig_get();
isc_log_createandusechannel(

View File

@ -105,7 +105,7 @@ main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
dns_log_init();

View File

@ -139,7 +139,7 @@ main(int argc, char *argv[]) {
}
isc_commandline_reset = true;
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
switch (ch) {

View File

@ -375,7 +375,7 @@ main(int argc, char *argv[]) {
fatal("no file specified");
}
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
CHECKM(dns_dt_open(argv[0], dns_dtmode_file, mctx, &handle),
"dns_dt_openfile");

View File

@ -93,7 +93,7 @@ main(int argc, char **argv) {
}
file = argv[0];
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
setup_logging(stderr);
if (upgrade) {

View File

@ -170,7 +170,7 @@ main(int argc, char *argv[]) {
exit(EXIT_SUCCESS);
}
isc_mem_create(&mctx);
isc_mem_create(argv[0], &mctx);
isc_lex_create(mctx, 256, &lex);
/*

View File

@ -449,7 +449,7 @@ memory has not been freed when BIND shuts down.
To create a basic memory context, use:
isc_mem_t *mctx = NULL;
isc_mem_create(&mctx);
isc_mem_create("name", &mctx);
When holding a persistent reference to a memory context it is advisable to
increment its reference counter using `isc_mem_attach()`. Do not just

View File

@ -61,7 +61,7 @@ main(int argc, char **argv) {
unsigned int zonetype = 0;
unsigned int pflags = 0;
isc_mem_create(&mctx);
isc_mem_create("misc", &mctx);
setup_logging();

View File

@ -48,7 +48,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
dns_rdatacallbacks_init(&callbacks);
dns_db_t *db = NULL;
isc_mem_create(&mctx);
isc_mem_create("fuzz", &mctx);
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
&db);

View File

@ -169,7 +169,7 @@ LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
fputs(c3, fd);
fclose(fd);
isc_mem_create(&mctx);
isc_mem_create("fuzz", &mctx);
isc_loopmgr_create(mctx, 1, &loopmgr);

View File

@ -36,7 +36,7 @@ static uint8_t render_buf[64 * 1024 - 1];
int
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
isc_mem_create(&mctx);
isc_mem_create("fuzz", &mctx);
output = isc_mem_get(mctx, output_len);
return 0;

View File

@ -122,7 +122,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
TRACE("------------------------------------------------");
isc_mem_t *mctx = NULL;
isc_mem_create(&mctx);
isc_mem_create("fuzz", &mctx);
isc_mem_setdestroycheck(mctx, true);
dns_qp_t *qp = NULL;

View File

@ -46,7 +46,7 @@ isc_lexspecials_t specials = { ['('] = 1, [')'] = 1, ['"'] = 1 };
int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
isc_mem_t *mctx = NULL;
isc_mem_create(&mctx);
isc_mem_create("fuzz", &mctx);
isc_lex_t *lex = NULL;
isc_token_t token;

View File

@ -45,7 +45,7 @@ int
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
isc_lexspecials_t specials;
isc_mem_create(&mctx);
isc_mem_create("fuzz", &mctx);
isc_lex_create(mctx, 64, &lex);
memset(specials, 0, sizeof(specials));

View File

@ -35,7 +35,7 @@ static isc_lex_t *lex = NULL;
int
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
isc_mem_create(&mctx);
isc_mem_create("fuzz", &mctx);
isc_lex_create(mctx, 1024, &lex);
return 0;

View File

@ -28,7 +28,7 @@ static isc_lex_t *lex = NULL;
int
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
isc_mem_create(&mctx);
isc_mem_create("fuzz", &mctx);
isc_lex_create(mctx, 1024, &lex);
return 0;

View File

@ -1732,8 +1732,7 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, dns_adb_t **newadb) {
dns_resolver_attach(view->resolver, &adb->res);
isc_mem_attach(mem, &adb->mctx);
isc_mem_create(&adb->hmctx);
isc_mem_setname(adb->hmctx, "ADB_dynamic");
isc_mem_create("ADB_dynamic", &adb->hmctx);
isc_hashmap_create(adb->hmctx, ADB_HASH_BITS, &adb->names);
isc_rwlock_init(&adb->names_lock);

View File

@ -100,8 +100,7 @@ cache_create_db(dns_cache_t *cache, dns_db_t **dbp, isc_mem_t **tmctxp,
* This will be the cache memory context, which is subject
* to cleaning when the configured memory limits are exceeded.
*/
isc_mem_create(&tmctx);
isc_mem_setname(tmctx, "cache");
isc_mem_create("cache", &tmctx);
/*
* This will be passed to RBTDB to use for heaps. This is separate
@ -109,8 +108,7 @@ cache_create_db(dns_cache_t *cache, dns_db_t **dbp, isc_mem_t **tmctxp,
* heavy load and could otherwise cause the cache to be cleaned too
* aggressively.
*/
isc_mem_create(&hmctx);
isc_mem_setname(hmctx, "cache_heap");
isc_mem_create("cache_heap", &hmctx);
/*
* For databases of type "qpcache" or "rbt" (which are the

View File

@ -190,8 +190,7 @@ static isc_mem_t *dst__mctx = NULL;
void
dst__lib_initialize(void) {
isc_mem_create(&dst__mctx);
isc_mem_setname(dst__mctx, "dst");
isc_mem_create("dst", &dst__mctx);
dst__hmacmd5_init(&dst_t_func[DST_ALG_HMACMD5]);
dst__hmacsha1_init(&dst_t_func[DST_ALG_HMACSHA1]);

View File

@ -5070,15 +5070,15 @@ dns_message_createpools(isc_mem_t *mctx, isc_mempool_t **namepoolp,
REQUIRE(namepoolp != NULL && *namepoolp == NULL);
REQUIRE(rdspoolp != NULL && *rdspoolp == NULL);
isc_mempool_create(mctx, sizeof(dns_fixedname_t), namepoolp);
isc_mempool_create(mctx, sizeof(dns_fixedname_t), "dns_fixedname_pool",
namepoolp);
isc_mempool_setfillcount(*namepoolp, NAME_FILLCOUNT);
isc_mempool_setfreemax(*namepoolp, NAME_FREEMAX);
isc_mempool_setname(*namepoolp, "dns_fixedname_pool");
isc_mempool_create(mctx, sizeof(dns_rdataset_t), rdspoolp);
isc_mempool_create(mctx, sizeof(dns_rdataset_t), "dns_rdataset_pool",
rdspoolp);
isc_mempool_setfillcount(*rdspoolp, RDATASET_FILLCOUNT);
isc_mempool_setfreemax(*rdspoolp, RDATASET_FREEMAX);
isc_mempool_setname(*rdspoolp, "dns_rdataset_pool");
}
void

View File

@ -536,8 +536,7 @@ dns_view_createresolver(dns_view_t *view, isc_nm_t *netmgr,
return result;
}
isc_mem_create(&mctx);
isc_mem_setname(mctx, "ADB");
isc_mem_create("ADB", &mctx);
dns_adb_create(mctx, view, &view->adb);
isc_mem_detach(&mctx);

View File

@ -19052,8 +19052,7 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_nm_t *netmgr, dns_zonemgr_t **zmgrp) {
zmgr->mctxpool = isc_mem_cget(zmgr->mctx, zmgr->workers,
sizeof(zmgr->mctxpool[0]));
for (size_t i = 0; i < zmgr->workers; i++) {
isc_mem_create(&zmgr->mctxpool[i]);
isc_mem_setname(zmgr->mctxpool[i], "zonemgr-mctxpool");
isc_mem_create("zonemgr-mctxpool", &zmgr->mctxpool[i]);
}
/* Key file I/O locks. */

View File

@ -252,8 +252,7 @@ void
isc__crypto_initialize(void) {
uint64_t opts = OPENSSL_INIT_LOAD_CONFIG;
isc_mem_create(&isc__crypto_mctx);
isc_mem_setname(isc__crypto_mctx, "OpenSSL");
isc_mem_create("OpenSSL", &isc__crypto_mctx);
isc_mem_setdestroycheck(isc__crypto_mctx, false);
#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x30000000L

View File

@ -200,17 +200,17 @@ mallocx(size_t size, int flags);
extern volatile void *isc__mem_malloc;
#define isc_mem_create(cp) \
#define isc_mem_create(name, cp) \
{ \
isc__mem_create((cp)_ISC_MEM_FILELINE); \
isc__mem_create((name), (cp)_ISC_MEM_FILELINE); \
isc__mem_malloc = mallocx; \
ISC_INSIST(CMM_ACCESS_ONCE(isc__mem_malloc) != NULL); \
}
#else
#define isc_mem_create(cp) isc__mem_create((cp)_ISC_MEM_FILELINE)
#define isc_mem_create(name, cp) isc__mem_create((name), (cp)_ISC_MEM_FILELINE)
#endif
void
isc__mem_create(isc_mem_t **_ISC_MEM_FLARG);
isc__mem_create(const char *name, isc_mem_t **_ISC_MEM_FLARG);
/*!<
* \brief Create a memory context.
@ -219,9 +219,10 @@ isc__mem_create(isc_mem_t **_ISC_MEM_FLARG);
* mctxp != NULL && *mctxp == NULL */
/*@}*/
#define isc_mem_create_arena(cp) isc__mem_create_arena((cp)_ISC_MEM_FILELINE)
#define isc_mem_create_arena(name, cp) \
isc__mem_create_arena((name), (cp)_ISC_MEM_FILELINE)
void
isc__mem_create_arena(isc_mem_t **_ISC_MEM_FLARG);
isc__mem_create_arena(const char *name, isc_mem_t **_ISC_MEM_FLARG);
/*!<
* \brief Create a memory context that routs all its operations to a
* dedicated jemalloc arena (when available). When jemalloc is not
@ -325,20 +326,6 @@ isc_mem_references(isc_mem_t *ctx);
* Return the current reference count.
*/
void
isc_mem_setname(isc_mem_t *ctx, const char *name);
/*%<
* Name 'ctx'.
*
* Notes:
*
*\li Only the first 15 characters of 'name' will be copied.
*
* Requires:
*
*\li 'ctx' is a valid ctx.
*/
const char *
isc_mem_getname(isc_mem_t *ctx);
/*%<
@ -373,11 +360,11 @@ isc_mem_renderjson(void *memobj0);
* Memory pools
*/
#define isc_mempool_create(c, s, mp) \
isc__mempool_create((c), (s), (mp)_ISC_MEM_FILELINE)
#define isc_mempool_create(c, s, n, mp) \
isc__mempool_create((c), (s), (n), (mp)_ISC_MEM_FILELINE)
void
isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
isc_mempool_t **mpctxp _ISC_MEM_FLARG);
const char *name, isc_mempool_t **mpctxp _ISC_MEM_FLARG);
/*%<
* Create a memory pool.
*
@ -402,17 +389,6 @@ isc__mempool_destroy(isc_mempool_t **restrict mpctxp _ISC_MEM_FLARG);
*\li The pool has no un"put" allocations outstanding
*/
void
isc_mempool_setname(isc_mempool_t *restrict mpctx, const char *name);
/*%<
* Associate a name with a memory pool. At most 15 characters may be
*used.
*
* Requires:
*\li mpctx is a valid pool.
*\li name != NULL;
*/
/*
* The following functions get/set various parameters. Note that due to
* the unlocked nature of pools these are potentially random values

View File

@ -1551,7 +1551,7 @@ isc__log_initialize(void) {
isc_mem_t *mctx = NULL;
isc_mem_create(&mctx);
isc_mem_create("log", &mctx);
isc__lctx = isc_mem_get(mctx, sizeof(*isc__lctx));
*isc__lctx = (isc_log_t){

View File

@ -226,10 +226,7 @@ loop_init(isc_loop_t *loop, isc_loopmgr_t *loopmgr, uint32_t tid,
UV_RUNTIME_CHECK(uv_prepare_init, r);
uv_handle_set_data(&loop->quiescent, loop);
char name[16];
snprintf(name, sizeof(name), "%s-%08" PRIx32, kind, tid);
isc_mem_create(&loop->mctx);
isc_mem_setname(loop->mctx, name);
isc_mem_create(kind, &loop->mctx);
isc_refcount_init(&loop->references, 1);

View File

@ -20,9 +20,8 @@ void
isc_managers_create(isc_mem_t **mctxp, uint32_t workers,
isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp) {
REQUIRE(mctxp != NULL && *mctxp == NULL);
isc_mem_create(mctxp);
isc_mem_create("managers", mctxp);
INSIST(*mctxp != NULL);
isc_mem_setname(*mctxp, "managers");
REQUIRE(loopmgrp != NULL && *loopmgrp == NULL);
isc_loopmgr_create(*mctxp, workers, loopmgrp);

View File

@ -123,7 +123,7 @@ struct isc_mem {
isc_mutex_t lock;
bool checkfree;
isc_refcount_t references;
char name[16];
char *name;
atomic_size_t inuse;
atomic_bool hi_called;
atomic_bool is_overmem;
@ -157,7 +157,7 @@ struct isc_mempool {
/*%< Stats only. */
size_t gets; /*%< # of requests to this pool */
/*%< Debugging only. */
char name[16]; /*%< printed name in stats reports */
char *name; /*%< printed name in stats reports */
};
/*
@ -450,11 +450,12 @@ isc__mem_shutdown(void) {
}
static void
mem_create(isc_mem_t **ctxp, unsigned int debugging, unsigned int flags,
unsigned int jemalloc_flags) {
mem_create(const char *name, isc_mem_t **ctxp, unsigned int debugging,
unsigned int flags, unsigned int jemalloc_flags) {
isc_mem_t *ctx = NULL;
REQUIRE(ctxp != NULL && *ctxp == NULL);
REQUIRE(name != NULL);
ctx = mallocx(sizeof(*ctx), jemalloc_flags);
INSIST(ctx != NULL);
@ -466,6 +467,7 @@ mem_create(isc_mem_t **ctxp, unsigned int debugging, unsigned int flags,
.jemalloc_flags = jemalloc_flags,
.jemalloc_arena = ISC_MEM_ILLEGAL_ARENA,
.checkfree = true,
.name = strdup(name),
};
isc_mutex_init(&ctx->lock);
@ -542,6 +544,8 @@ mem_destroy(isc_mem_t *ctx) {
}
#endif /* if ISC_MEM_TRACKLINES */
free(ctx->name);
isc_mutex_destroy(&ctx->lock);
if (ctx->checkfree) {
@ -900,15 +904,6 @@ isc_mem_isovermem(isc_mem_t *ctx) {
}
}
void
isc_mem_setname(isc_mem_t *ctx, const char *name) {
REQUIRE(VALID_CONTEXT(ctx));
LOCK(&ctx->lock);
strlcpy(ctx->name, name, sizeof(ctx->name));
UNLOCK(&ctx->lock);
}
const char *
isc_mem_getname(isc_mem_t *ctx) {
REQUIRE(VALID_CONTEXT(ctx));
@ -926,13 +921,14 @@ isc_mem_getname(isc_mem_t *ctx) {
void
isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
isc_mempool_t **restrict mpctxp FLARG) {
const char *name, isc_mempool_t **restrict mpctxp FLARG) {
isc_mempool_t *restrict mpctx = NULL;
size_t size = element_size;
REQUIRE(VALID_CONTEXT(mctx));
REQUIRE(size > 0U);
REQUIRE(mpctxp != NULL && *mpctxp == NULL);
REQUIRE(name != NULL);
/*
* Mempools are stored as a linked list of element.
@ -951,6 +947,7 @@ isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
.size = size,
.freemax = 1,
.fillcount = 1,
.name = strdup(name),
};
#if ISC_MEM_TRACKLINES
@ -972,14 +969,6 @@ isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
MCTXUNLOCK(mctx);
}
void
isc_mempool_setname(isc_mempool_t *restrict mpctx, const char *name) {
REQUIRE(VALID_MEMPOOL(mpctx));
REQUIRE(name != NULL);
strlcpy(mpctx->name, name, sizeof(mpctx->name));
}
void
isc__mempool_destroy(isc_mempool_t **restrict mpctxp FLARG) {
isc_mempool_t *restrict mpctx = NULL;
@ -1029,6 +1018,8 @@ isc__mempool_destroy(isc_mempool_t **restrict mpctxp FLARG) {
mctx->poolcnt--;
MCTXUNLOCK(mctx);
free(mpctx->name);
mpctx->magic = 0;
isc_mem_putanddetach(&mpctx->mctx, mpctx, sizeof(isc_mempool_t));
@ -1415,8 +1406,8 @@ error:
#endif /* HAVE_JSON_C */
void
isc__mem_create(isc_mem_t **mctxp FLARG) {
mem_create(mctxp, isc_mem_debugging, isc_mem_defaultflags, 0);
isc__mem_create(const char *name, isc_mem_t **mctxp FLARG) {
mem_create(name, mctxp, isc_mem_debugging, isc_mem_defaultflags, 0);
#if ISC_MEM_TRACKLINES
if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) {
fprintf(stderr, "create mctx %p func %s file %s line %u\n",
@ -1426,7 +1417,7 @@ isc__mem_create(isc_mem_t **mctxp FLARG) {
}
void
isc__mem_create_arena(isc_mem_t **mctxp FLARG) {
isc__mem_create_arena(const char *name, isc_mem_t **mctxp FLARG) {
unsigned int arena_no = ISC_MEM_ILLEGAL_ARENA;
RUNTIME_CHECK(mem_jemalloc_arena_create(&arena_no));
@ -1438,7 +1429,7 @@ isc__mem_create_arena(isc_mem_t **mctxp FLARG) {
*
* https://github.com/jemalloc/jemalloc/issues/2483#issuecomment-1698173849
*/
mem_create(mctxp, isc_mem_debugging, isc_mem_defaultflags,
mem_create(name, mctxp, isc_mem_debugging, isc_mem_defaultflags,
arena_no == ISC_MEM_ILLEGAL_ARENA
? 0
: MALLOCX_ARENA(arena_no) | MALLOCX_TCACHE_NONE);

View File

@ -223,12 +223,12 @@ isc_netmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t **netmgrp) {
isc_mem_attach(loop->mctx, &worker->mctx);
isc_mempool_create(worker->mctx, sizeof(isc_nmsocket_t),
&worker->nmsocket_pool);
"nmsocket_pool", &worker->nmsocket_pool);
isc_mempool_setfreemax(worker->nmsocket_pool,
ISC_NM_NMSOCKET_MAX);
isc_mempool_create(worker->mctx, sizeof(isc__nm_uvreq_t),
&worker->uvreq_pool);
"uvreq_pool", &worker->uvreq_pool);
isc_mempool_setfreemax(worker->uvreq_pool, ISC_NM_UVREQS_MAX);
isc_loop_attach(loop, &worker->loop);

View File

@ -132,8 +132,7 @@ void
isc__uv_initialize(void) {
#if UV_VERSION_HEX >= UV_VERSION(1, 38, 0)
int r;
isc_mem_create(&isc__uv_mctx);
isc_mem_setname(isc__uv_mctx, "uv");
isc_mem_create("uv", &isc__uv_mctx);
isc_mem_setdestroycheck(isc__uv_mctx, false);
r = uv_replace_allocator(isc__uv_malloc, isc__uv_realloc,

View File

@ -52,8 +52,7 @@ void
isc__xml_initialize(void) {
#ifdef HAVE_LIBXML2
#ifndef LIBXML_HAS_DEPRECATED_MEMORY_ALLOCATION_FUNCTIONS
isc_mem_create(&isc__xml_mctx);
isc_mem_setname(isc__xml_mctx, "libxml2");
isc_mem_create("libxml2", &isc__xml_mctx);
isc_mem_setdestroycheck(isc__xml_mctx, false);
RUNTIME_CHECK(xmlMemSetup(isc__xml_free, isc__xml_malloc,

View File

@ -2645,8 +2645,7 @@ ns_clientmgr_create(ns_server_t *sctx, isc_loopmgr_t *loopmgr,
ns_clientmgr_t *manager = NULL;
isc_mem_t *mctx = NULL;
isc_mem_create(&mctx);
isc_mem_setname(mctx, "clientmgr");
isc_mem_create("clientmgr", &mctx);
manager = isc_mem_get(mctx, sizeof(*manager));
*manager = (ns_clientmgr_t){

View File

@ -43,7 +43,7 @@ main(void) {
isc_buffer_t buf;
isc_mem_t *mctx = NULL;
isc_mem_create(&mctx);
isc_mem_create("test", &mctx);
static dns_fixedname_t fixedname[65536];
unsigned int count = 0;

View File

@ -420,7 +420,7 @@ main(int argc, char *argv[]) {
isc_rwlock_init(&rwl);
isc_mem_create(&mctx);
isc_mem_create("test", &mctx);
if (argc != 2) {
fprintf(stderr,
@ -494,7 +494,7 @@ main(int argc, char *argv[]) {
isc_mem_t *mem = NULL;
void *map = NULL;
isc_mem_create(&mem);
isc_mem_create("test", &mem);
map = fun->new(mem);
size_t nitems = lines / (nthreads + 1);

View File

@ -161,7 +161,7 @@ main(int argc, char *argv[]) {
exit(EXIT_SUCCESS);
}
isc_mem_create(&mctx);
isc_mem_create("test", &mctx);
filename = argv[0];
result = isc_file_getsize(filename, &fileoff);

View File

@ -197,7 +197,7 @@ main(int argc, char **argv) {
usage();
}
isc_mem_create(&mctx);
isc_mem_create("test", &mctx);
dns_qp_create(mctx, &methods, NULL, &qp);

View File

@ -876,7 +876,7 @@ main(void) {
}
INSIST(nloops > 1);
isc_mem_create(&mctx);
isc_mem_create("test", &mctx);
isc_mem_setdestroycheck(mctx, true);
init_logging();
init_items(mctx);

View File

@ -132,7 +132,7 @@ ISC_LOOP_TEST_IMPL(overmempurge_bigrdata) {
isc_stdtime_t now = isc_stdtime_now();
size_t i;
isc_mem_create(&mctx2);
isc_mem_create("test", &mctx2);
result = dns_db_create(mctx2, CACHEDB_DEFAULT, dns_rootname,
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
@ -183,7 +183,7 @@ ISC_LOOP_TEST_IMPL(overmempurge_longname) {
isc_stdtime_t now = isc_stdtime_now();
size_t i;
isc_mem_create(&mctx2);
isc_mem_create("test", &mctx2);
result = dns_db_create(mctx2, CACHEDB_DEFAULT, dns_rootname,
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,

View File

@ -56,8 +56,8 @@ ISC_RUN_TEST_IMPL(isc_mem_get) {
unsigned int i, j;
int rval;
isc_mempool_create(mctx, 24, &mp1);
isc_mempool_create(mctx, 31, &mp2);
isc_mempool_create(mctx, 24, "mp1", &mp1);
isc_mempool_create(mctx, 31, "mp2", &mp2);
isc_mempool_setfreemax(mp1, MP1_FREEMAX);
isc_mempool_setfillcount(mp1, MP1_FILLCNT);
@ -114,7 +114,7 @@ ISC_RUN_TEST_IMPL(isc_mem_get) {
isc_mempool_destroy(&mp1);
isc_mempool_destroy(&mp2);
isc_mempool_create(mctx, 2, &mp1);
isc_mempool_create(mctx, 2, "mp1", &mp1);
tmp = isc_mempool_get(mp1);
assert_non_null(tmp);
@ -183,7 +183,7 @@ ISC_RUN_TEST_IMPL(isc_mem_inuse) {
void *ptr;
mctx2 = NULL;
isc_mem_create(&mctx2);
isc_mem_create("test", &mctx2);
before = isc_mem_inuse(mctx2);
ptr = isc_mem_allocate(mctx2, 1024000);
@ -291,7 +291,7 @@ ISC_RUN_TEST_IMPL(isc_mem_reallocate) {
ISC_RUN_TEST_IMPL(isc_mem_overmem) {
isc_mem_t *omctx = NULL;
isc_mem_create(&omctx);
isc_mem_create("test", &omctx);
assert_non_null(omctx);
isc_mem_setwater(omctx, 1024, 512);
@ -337,7 +337,7 @@ ISC_RUN_TEST_IMPL(isc_mem_noflags) {
assert_int_equal(result, ISC_R_SUCCESS);
isc_mem_debugging = 0;
isc_mem_create(&mctx2);
isc_mem_create("test", &mctx2);
ptr = isc_mem_get(mctx2, 2048);
assert_non_null(ptr);
isc__mem_printactive(mctx2, f);
@ -373,7 +373,7 @@ ISC_RUN_TEST_IMPL(isc_mem_recordflag) {
result = isc_stdio_open("mem.output", "w", &f);
assert_int_equal(result, ISC_R_SUCCESS);
isc_mem_create(&mctx2);
isc_mem_create("test", &mctx2);
ptr = isc_mem_get(mctx2, 2048);
assert_non_null(ptr);
@ -437,7 +437,7 @@ ISC_RUN_TEST_IMPL(isc_mem_traceflag) {
assert_non_null(f);
isc_mem_debugging = ISC_MEM_DEBUGRECORD | ISC_MEM_DEBUGTRACE;
isc_mem_create(&mctx2);
isc_mem_create("test", &mctx2);
ptr = isc_mem_get(mctx2, 2048);
assert_non_null(ptr);
isc__mem_printactive(mctx2, f);

View File

@ -72,7 +72,7 @@ setup_workers(void **state ISC_ATTR_UNUSED) {
int
setup_mctx(void **state ISC_ATTR_UNUSED) {
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
isc_mem_create(&mctx);
isc_mem_create("test", &mctx);
return 0;
}