mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-08 18:32:10 -04:00
Use designated initializers instead of memset()/MEM_ZERO for structs
In several places, the structures were cleaned with memset(...)) and thus the semantic patch converted the isc_mem_get(...) to isc_mem_getx(..., ISC_MEM_ZERO). Use the designated initializer to initialized the structures instead of zeroing the memory with ISC_MEM_ZERO flag as this better matches the intended purpose.
This commit is contained in:
parent
c1d26b53eb
commit
c0598d404c
20 changed files with 179 additions and 158 deletions
|
|
@ -946,10 +946,12 @@ addserver(dns_client_t *client) {
|
|||
cur->ai_family != AF_INET6) {
|
||||
continue;
|
||||
}
|
||||
sa = isc_mem_getx(mctx, sizeof(*sa), ISC_MEM_ZERO);
|
||||
sa = isc_mem_get(mctx, sizeof(*sa));
|
||||
*sa = (isc_sockaddr_t){
|
||||
.length = (unsigned int)cur->ai_addrlen,
|
||||
};
|
||||
ISC_LINK_INIT(sa, link);
|
||||
memmove(&sa->type, cur->ai_addr, cur->ai_addrlen);
|
||||
sa->length = (unsigned int)cur->ai_addrlen;
|
||||
ISC_LIST_APPEND(servers, sa, link);
|
||||
}
|
||||
freeaddrinfo(res);
|
||||
|
|
|
|||
|
|
@ -2007,7 +2007,8 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
|
|||
}
|
||||
if (!state) {
|
||||
if (lookup->ecs_addr != NULL) {
|
||||
isc_mem_free(mctx, lookup->ecs_addr);
|
||||
isc_mem_put(mctx, lookup->ecs_addr,
|
||||
sizeof(*lookup->ecs_addr));
|
||||
lookup->ecs_addr = NULL;
|
||||
}
|
||||
break;
|
||||
|
|
@ -2016,7 +2017,8 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
|
|||
lookup->edns = DEFAULT_EDNS_VERSION;
|
||||
}
|
||||
if (lookup->ecs_addr != NULL) {
|
||||
isc_mem_free(mctx, lookup->ecs_addr);
|
||||
isc_mem_put(mctx, lookup->ecs_addr,
|
||||
sizeof(*lookup->ecs_addr));
|
||||
lookup->ecs_addr = NULL;
|
||||
}
|
||||
result = parse_netprefix(&lookup->ecs_addr, value);
|
||||
|
|
|
|||
|
|
@ -802,9 +802,10 @@ clone_lookup(dig_lookup_t *lookold, bool servers) {
|
|||
looknew->fuzztime = lookold->fuzztime;
|
||||
|
||||
if (lookold->ecs_addr != NULL) {
|
||||
size_t len = sizeof(isc_sockaddr_t);
|
||||
looknew->ecs_addr = isc_mem_allocate(mctx, len);
|
||||
memmove(looknew->ecs_addr, lookold->ecs_addr, len);
|
||||
looknew->ecs_addr = isc_mem_get(mctx,
|
||||
sizeof(*looknew->ecs_addr));
|
||||
memmove(looknew->ecs_addr, lookold->ecs_addr,
|
||||
sizeof(*looknew->ecs_addr));
|
||||
}
|
||||
|
||||
dns_name_copy(dns_fixedname_name(&lookold->fdomain),
|
||||
|
|
@ -963,7 +964,8 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
|
|||
fatal("invalid prefix '%s'\n", value);
|
||||
}
|
||||
|
||||
sa = isc_mem_allocatex(mctx, sizeof(*sa), ISC_MEM_ZERO);
|
||||
sa = isc_mem_get(mctx, sizeof(*sa));
|
||||
*sa = (isc_sockaddr_t){ .length = 0 };
|
||||
|
||||
if (strcmp(buf, "0") == 0) {
|
||||
sa->type.sa.sa_family = AF_UNSPEC;
|
||||
|
|
@ -1604,7 +1606,7 @@ _destroy_lookup(dig_lookup_t *lookup) {
|
|||
}
|
||||
|
||||
if (lookup->ecs_addr != NULL) {
|
||||
isc_mem_free(mctx, lookup->ecs_addr);
|
||||
isc_mem_put(mctx, lookup->ecs_addr, sizeof(*lookup->ecs_addr));
|
||||
}
|
||||
|
||||
if (lookup->ednsopts != NULL) {
|
||||
|
|
|
|||
|
|
@ -519,7 +519,7 @@ match_keyset_dsset(dns_rdataset_t *keyset, dns_rdataset_t *dsset,
|
|||
|
||||
nkey = dns_rdataset_count(keyset);
|
||||
|
||||
keytable = isc_mem_get(mctx, sizeof(keyinfo_t) * nkey);
|
||||
keytable = isc_mem_getx(mctx, sizeof(keytable[0]) * nkey, ISC_MEM_ZERO);
|
||||
|
||||
for (result = dns_rdataset_first(keyset), i = 0;
|
||||
result == ISC_R_SUCCESS; result = dns_rdataset_next(keyset), i++)
|
||||
|
|
@ -575,7 +575,7 @@ free_keytable(keyinfo_t **keytable_p) {
|
|||
}
|
||||
}
|
||||
|
||||
isc_mem_put(mctx, keytable, sizeof(keyinfo_t) * nkey);
|
||||
isc_mem_put(mctx, keytable, sizeof(keytable[0]) * nkey);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -594,7 +594,7 @@ matching_sigs(keyinfo_t *keytbl, dns_rdataset_t *rdataset,
|
|||
dns_secalg_t *algo;
|
||||
int i;
|
||||
|
||||
algo = isc_mem_getx(mctx, nkey, ISC_MEM_ZERO);
|
||||
algo = isc_mem_getx(mctx, nkey * sizeof(algo[0]), ISC_MEM_ZERO);
|
||||
|
||||
for (result = dns_rdataset_first(sigset); result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(sigset))
|
||||
|
|
@ -676,7 +676,7 @@ signed_loose(dns_secalg_t *algo) {
|
|||
ok = true;
|
||||
}
|
||||
}
|
||||
isc_mem_put(mctx, algo, nkey);
|
||||
isc_mem_put(mctx, algo, nkey * sizeof(algo[0]));
|
||||
return (ok);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,12 +224,12 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
}
|
||||
|
||||
isc_mem_create(&mctx);
|
||||
cd = isc_mem_getx(mctx, sizeof(*cd), ISC_MEM_ZERO);
|
||||
|
||||
cd->mctx = mctx;
|
||||
|
||||
cd->dl_path = isc_mem_strdup(cd->mctx, argv[1]);
|
||||
cd->dlzname = isc_mem_strdup(cd->mctx, dlzname);
|
||||
cd = isc_mem_get(mctx, sizeof(*cd));
|
||||
*cd = (dlopen_data_t){
|
||||
.mctx = mctx,
|
||||
.dl_path = isc_mem_strdup(mctx, argv[1]),
|
||||
.dlzname = isc_mem_strdup(mctx, dlzname),
|
||||
};
|
||||
|
||||
/* Initialize the lock */
|
||||
isc_mutex_init(&cd->lock);
|
||||
|
|
|
|||
|
|
@ -338,7 +338,8 @@ plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
|
|||
"module from %s:%lu, %s parameters",
|
||||
cfg_file, cfg_line, parameters != NULL ? "with" : "no");
|
||||
|
||||
inst = isc_mem_getx(mctx, sizeof(*inst), ISC_MEM_ZERO);
|
||||
inst = isc_mem_get(mctx, sizeof(*inst));
|
||||
*inst = (filter_instance_t){ 0 };
|
||||
isc_mem_attach(mctx, &inst->mctx);
|
||||
|
||||
if (parameters != NULL) {
|
||||
|
|
|
|||
|
|
@ -341,7 +341,9 @@ plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
|
|||
"module from %s:%lu, %s parameters",
|
||||
cfg_file, cfg_line, parameters != NULL ? "with" : "no");
|
||||
|
||||
inst = isc_mem_getx(mctx, sizeof(*inst), ISC_MEM_ZERO);
|
||||
inst = isc_mem_get(mctx, sizeof(*inst));
|
||||
*inst = (filter_instance_t){ 0 };
|
||||
|
||||
isc_mem_attach(mctx, &inst->mctx);
|
||||
|
||||
if (parameters != NULL) {
|
||||
|
|
|
|||
|
|
@ -74,21 +74,24 @@ dns_badcache_init(isc_mem_t *mctx, unsigned int size, dns_badcache_t **bcp) {
|
|||
REQUIRE(bcp != NULL && *bcp == NULL);
|
||||
REQUIRE(mctx != NULL);
|
||||
|
||||
bc = isc_mem_getx(mctx, sizeof(dns_badcache_t), ISC_MEM_ZERO);
|
||||
bc = isc_mem_get(mctx, sizeof(*bc));
|
||||
|
||||
*bc = (dns_badcache_t){
|
||||
.size = size,
|
||||
.minsize = size,
|
||||
};
|
||||
|
||||
isc_mem_attach(mctx, &bc->mctx);
|
||||
isc_rwlock_init(&bc->lock, 0, 0);
|
||||
|
||||
bc->table = isc_mem_get(bc->mctx, sizeof(*bc->table) * size);
|
||||
bc->tlocks = isc_mem_get(bc->mctx, sizeof(isc_mutex_t) * size);
|
||||
bc->table = isc_mem_getx(bc->mctx, sizeof(bc->table[0]) * size,
|
||||
ISC_MEM_ZERO);
|
||||
bc->tlocks = isc_mem_getx(bc->mctx, sizeof(bc->tlocks[0]) * size,
|
||||
ISC_MEM_ZERO);
|
||||
for (i = 0; i < size; i++) {
|
||||
isc_mutex_init(&bc->tlocks[i]);
|
||||
}
|
||||
bc->size = bc->minsize = size;
|
||||
memset(bc->table, 0, bc->size * sizeof(dns_bcentry_t *));
|
||||
|
||||
atomic_init(&bc->count, 0);
|
||||
atomic_init(&bc->sweep, 0);
|
||||
bc->magic = BADCACHE_MAGIC;
|
||||
|
||||
*bcp = bc;
|
||||
|
|
@ -111,8 +114,8 @@ dns_badcache_destroy(dns_badcache_t **bcp) {
|
|||
for (i = 0; i < bc->size; i++) {
|
||||
isc_mutex_destroy(&bc->tlocks[i]);
|
||||
}
|
||||
isc_mem_put(bc->mctx, bc->table, sizeof(dns_bcentry_t *) * bc->size);
|
||||
isc_mem_put(bc->mctx, bc->tlocks, sizeof(isc_mutex_t) * bc->size);
|
||||
isc_mem_put(bc->mctx, bc->table, sizeof(bc->table[0]) * bc->size);
|
||||
isc_mem_put(bc->mctx, bc->tlocks, sizeof(bc->tlocks[0]) * bc->size);
|
||||
isc_mem_putanddetach(&bc->mctx, bc, sizeof(dns_badcache_t));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -199,10 +199,12 @@ dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername,
|
|||
}
|
||||
|
||||
/* Allocate memory to hold the DLZ database driver */
|
||||
db = isc_mem_getx(mctx, sizeof(dns_dlzdb_t), ISC_MEM_ZERO);
|
||||
db = isc_mem_get(mctx, sizeof(*db));
|
||||
*db = (dns_dlzdb_t){
|
||||
.implementation = impinfo,
|
||||
};
|
||||
|
||||
ISC_LINK_INIT(db, link);
|
||||
db->implementation = impinfo;
|
||||
if (dlzname != NULL) {
|
||||
db->dlzname = isc_mem_strdup(mctx, dlzname);
|
||||
}
|
||||
|
|
@ -211,26 +213,25 @@ dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername,
|
|||
result = ((impinfo->methods->create)(mctx, dlzname, argc, argv,
|
||||
impinfo->driverarg, &db->dbdata));
|
||||
|
||||
RWUNLOCK(&dlz_implock, isc_rwlocktype_read);
|
||||
/* mark the DLZ driver as valid */
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
RWUNLOCK(&dlz_implock, isc_rwlocktype_read);
|
||||
db->magic = DNS_DLZ_MAGIC;
|
||||
isc_mem_attach(mctx, &db->mctx);
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
||||
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(2),
|
||||
"DLZ driver loaded successfully.");
|
||||
*dbp = db;
|
||||
return (ISC_R_SUCCESS);
|
||||
} else {
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
||||
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
|
||||
"DLZ driver failed to load.");
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto failure;
|
||||
}
|
||||
|
||||
db->magic = DNS_DLZ_MAGIC;
|
||||
isc_mem_attach(mctx, &db->mctx);
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
|
||||
ISC_LOG_DEBUG(2), "DLZ driver loaded successfully.");
|
||||
*dbp = db;
|
||||
return (ISC_R_SUCCESS);
|
||||
failure:
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
|
||||
ISC_LOG_ERROR, "DLZ driver failed to load.");
|
||||
|
||||
/* impinfo->methods->create failed. */
|
||||
RWUNLOCK(&dlz_implock, isc_rwlocktype_read);
|
||||
isc_mem_free(mctx, db->dlzname);
|
||||
isc_mem_put(mctx, db, sizeof(dns_dlzdb_t));
|
||||
isc_mem_put(mctx, db, sizeof(*db));
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
|
@ -262,7 +263,7 @@ dns_dlzdestroy(dns_dlzdb_t **dbp) {
|
|||
destroy = db->implementation->methods->destroy;
|
||||
(*destroy)(db->implementation->driverarg, db->dbdata);
|
||||
/* return memory and detach */
|
||||
isc_mem_putanddetach(&db->mctx, db, sizeof(dns_dlzdb_t));
|
||||
isc_mem_putanddetach(&db->mctx, db, sizeof(*db));
|
||||
}
|
||||
|
||||
/*%
|
||||
|
|
@ -317,14 +318,12 @@ dns_dlzregister(const char *drivername, const dns_dlzmethods_t *methods,
|
|||
* Allocate memory for a dlz_implementation object. Error if
|
||||
* we cannot.
|
||||
*/
|
||||
dlz_imp = isc_mem_getx(mctx, sizeof(dns_dlzimplementation_t),
|
||||
ISC_MEM_ZERO);
|
||||
|
||||
/* Store the data passed into this method */
|
||||
dlz_imp->name = drivername;
|
||||
dlz_imp->methods = methods;
|
||||
dlz_imp->mctx = NULL;
|
||||
dlz_imp->driverarg = driverarg;
|
||||
dlz_imp = isc_mem_get(mctx, sizeof(*dlz_imp));
|
||||
*dlz_imp = (dns_dlzimplementation_t){
|
||||
.name = drivername,
|
||||
.methods = methods,
|
||||
.driverarg = driverarg,
|
||||
};
|
||||
|
||||
/* attach the new dlz_implementation object to a memory context */
|
||||
isc_mem_attach(mctx, &dlz_imp->mctx);
|
||||
|
|
|
|||
|
|
@ -257,7 +257,15 @@ dns_dnsrps_rewrite_init(librpz_emsg_t *emsg, dns_rpz_st_t *st,
|
|||
isc_mem_t *mctx, bool have_rd) {
|
||||
rpsdb_t *rpsdb;
|
||||
|
||||
rpsdb = isc_mem_getx(mctx, sizeof(*rpsdb), ISC_MEM_ZERO);
|
||||
rpsdb = isc_mem_get(mctx, sizeof(*rpsdb));
|
||||
*rpsdb = (rpsdb_t){
|
||||
.common = {
|
||||
.methods = &rpsdb_db_methods,
|
||||
.rdclass = dns_rdataclass_in,
|
||||
},
|
||||
.ref_cnt = 1,
|
||||
.qname = qname,
|
||||
};
|
||||
|
||||
if (!librpz->rsp_create(emsg, &rpsdb->rsp, NULL, rpzs->rps_client,
|
||||
have_rd, false))
|
||||
|
|
@ -272,14 +280,9 @@ dns_dnsrps_rewrite_init(librpz_emsg_t *emsg, dns_rpz_st_t *st,
|
|||
|
||||
rpsdb->common.magic = DNS_DB_MAGIC;
|
||||
rpsdb->common.impmagic = RPSDB_MAGIC;
|
||||
rpsdb->common.methods = &rpsdb_db_methods;
|
||||
rpsdb->common.rdclass = dns_rdataclass_in;
|
||||
dns_name_init(&rpsdb->common.origin, NULL);
|
||||
isc_mem_attach(mctx, &rpsdb->common.mctx);
|
||||
|
||||
rpsdb->ref_cnt = 1;
|
||||
rpsdb->qname = qname;
|
||||
|
||||
st->rpsdb = &rpsdb->common;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
@ -630,11 +633,15 @@ rpsdb_allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
|||
REQUIRE(VALID_RPSDB(rpsdb));
|
||||
REQUIRE(node == &rpsdb->origin_node || node == &rpsdb->data_node);
|
||||
|
||||
rpsdb_iter = isc_mem_getx(rpsdb->common.mctx, sizeof(*rpsdb_iter),
|
||||
ISC_MEM_ZERO);
|
||||
rpsdb_iter->common.magic = DNS_RDATASETITER_MAGIC;
|
||||
rpsdb_iter->common.methods = &rpsdb_rdatasetiter_methods;
|
||||
rpsdb_iter->common.db = db;
|
||||
rpsdb_iter = isc_mem_get(rpsdb->common.mctx, sizeof(*rpsdb_iter));
|
||||
*rpsdb_iter = ( rpsdb_rdatasetiter_t){
|
||||
|
||||
.common= {.magic = DNS_RDATASETITER_MAGIC,
|
||||
.methods = &rpsdb_rdatasetiter_methods,
|
||||
.db = db,
|
||||
},
|
||||
};
|
||||
|
||||
rpsdb_attachnode(db, node, &rpsdb_iter->common.node);
|
||||
|
||||
*iteratorp = &rpsdb_iter->common;
|
||||
|
|
|
|||
|
|
@ -161,11 +161,14 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
|
|||
|
||||
atomic_fetch_add_release(&global_generation, 1);
|
||||
|
||||
env = isc_mem_getx(mctx, sizeof(dns_dtenv_t), ISC_MEM_ZERO);
|
||||
env = isc_mem_get(mctx, sizeof(*env));
|
||||
*env = (dns_dtenv_t){
|
||||
.reopen_task = reopen_task,
|
||||
.reopen_queued = false,
|
||||
};
|
||||
|
||||
isc_mem_attach(mctx, &env->mctx);
|
||||
env->reopen_task = reopen_task;
|
||||
isc_mutex_init(&env->reopen_lock);
|
||||
env->reopen_queued = false;
|
||||
env->path = isc_mem_strdup(env->mctx, path);
|
||||
isc_refcount_init(&env->refcount, 1);
|
||||
CHECK(isc_stats_create(env->mctx, &env->stats, dns_dnstapcounter_max));
|
||||
|
|
|
|||
|
|
@ -283,15 +283,14 @@ dst_context_create(dst_key_t *key, isc_mem_t *mctx, isc_logcategory_t *category,
|
|||
return (DST_R_NULLKEY);
|
||||
}
|
||||
|
||||
dctx = isc_mem_getx(mctx, sizeof(*dctx), ISC_MEM_ZERO);
|
||||
dctx = isc_mem_get(mctx, sizeof(*dctx));
|
||||
*dctx = (dst_context_t){
|
||||
.category = category,
|
||||
.use = (useforsigning) ? DO_SIGN : DO_VERIFY,
|
||||
};
|
||||
|
||||
dst_key_attach(key, &dctx->key);
|
||||
isc_mem_attach(mctx, &dctx->mctx);
|
||||
dctx->category = category;
|
||||
if (useforsigning) {
|
||||
dctx->use = DO_SIGN;
|
||||
} else {
|
||||
dctx->use = DO_VERIFY;
|
||||
}
|
||||
if (key->func->createctx2 != NULL) {
|
||||
result = key->func->createctx2(key, maxbits, dctx);
|
||||
} else {
|
||||
|
|
@ -1521,33 +1520,27 @@ get_key_struct(const dns_name_t *name, unsigned int alg, unsigned int flags,
|
|||
unsigned int protocol, unsigned int bits,
|
||||
dns_rdataclass_t rdclass, dns_ttl_t ttl, isc_mem_t *mctx) {
|
||||
dst_key_t *key;
|
||||
int i;
|
||||
|
||||
key = isc_mem_getx(mctx, sizeof(dst_key_t), ISC_MEM_ZERO);
|
||||
|
||||
key->key_name = isc_mem_get(mctx, sizeof(dns_name_t));
|
||||
key = isc_mem_get(mctx, sizeof(dst_key_t));
|
||||
*key = (dst_key_t){
|
||||
.key_name = isc_mem_get(mctx, sizeof(dns_name_t)),
|
||||
.key_alg = alg,
|
||||
.key_flags = flags,
|
||||
.key_proto = protocol,
|
||||
.key_size = bits,
|
||||
.key_class = rdclass,
|
||||
.key_ttl = ttl,
|
||||
.func = dst_t_func[alg],
|
||||
};
|
||||
|
||||
dns_name_init(key->key_name, NULL);
|
||||
dns_name_dup(name, mctx, key->key_name);
|
||||
|
||||
isc_refcount_init(&key->refs, 1);
|
||||
isc_mem_attach(mctx, &key->mctx);
|
||||
key->key_alg = alg;
|
||||
key->key_flags = flags;
|
||||
key->key_proto = protocol;
|
||||
key->keydata.generic = NULL;
|
||||
key->key_size = bits;
|
||||
key->key_class = rdclass;
|
||||
key->key_ttl = ttl;
|
||||
key->func = dst_t_func[alg];
|
||||
key->fmt_major = 0;
|
||||
key->fmt_minor = 0;
|
||||
for (i = 0; i < (DST_MAX_TIMES + 1); i++) {
|
||||
key->times[i] = 0;
|
||||
key->timeset[i] = false;
|
||||
}
|
||||
|
||||
isc_mutex_init(&key->mdlock);
|
||||
key->inactive = false;
|
||||
|
||||
key->magic = KEY_MAGIC;
|
||||
return (key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,10 +126,12 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname,
|
|||
ISC_LOG_INFO, "loading DynDB instance '%s' driver '%s'",
|
||||
instname, filename);
|
||||
|
||||
imp = isc_mem_getx(mctx, sizeof(*imp), ISC_MEM_ZERO);
|
||||
isc_mem_attach(mctx, &imp->mctx);
|
||||
imp = isc_mem_get(mctx, sizeof(*imp));
|
||||
*imp = (dyndb_implementation_t){
|
||||
.name = isc_mem_strdup(mctx, instname),
|
||||
};
|
||||
|
||||
imp->name = isc_mem_strdup(imp->mctx, instname);
|
||||
isc_mem_attach(mctx, &imp->mctx);
|
||||
|
||||
INIT_LINK(imp, link);
|
||||
|
||||
|
|
@ -272,7 +274,14 @@ dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
|
|||
|
||||
REQUIRE(dctxp != NULL && *dctxp == NULL);
|
||||
|
||||
dctx = isc_mem_getx(mctx, sizeof(*dctx), ISC_MEM_ZERO);
|
||||
dctx = isc_mem_get(mctx, sizeof(*dctx));
|
||||
*dctx = (dns_dyndbctx_t){
|
||||
.loopmgr = loopmgr,
|
||||
.hashinit = hashinit,
|
||||
.lctx = lctx,
|
||||
.refvar = &isc_bind9,
|
||||
};
|
||||
|
||||
if (view != NULL) {
|
||||
dns_view_attach(view, &dctx->view);
|
||||
}
|
||||
|
|
@ -282,10 +291,6 @@ dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
|
|||
if (task != NULL) {
|
||||
isc_task_attach(task, &dctx->task);
|
||||
}
|
||||
dctx->loopmgr = loopmgr;
|
||||
dctx->hashinit = hashinit;
|
||||
dctx->lctx = lctx;
|
||||
dctx->refvar = &isc_bind9;
|
||||
|
||||
isc_mem_attach(mctx, &dctx->mctx);
|
||||
dctx->magic = DNS_DYNDBCTX_MAGIC;
|
||||
|
|
|
|||
|
|
@ -933,13 +933,12 @@ make_log_buf(dns_rrl_t *rrl, dns_rrl_entry_t *e, const char *str1,
|
|||
if (qbuf != NULL) {
|
||||
ISC_LIST_UNLINK(rrl->qname_free, qbuf, link);
|
||||
} else if (rrl->num_qnames < DNS_RRL_QNAMES) {
|
||||
qbuf = isc_mem_getx(rrl->mctx, sizeof(*qbuf),
|
||||
ISC_MEM_ZERO);
|
||||
{
|
||||
ISC_LINK_INIT(qbuf, link);
|
||||
qbuf->index = rrl->num_qnames;
|
||||
rrl->qnames[rrl->num_qnames++] = qbuf;
|
||||
}
|
||||
qbuf = isc_mem_get(rrl->mctx, sizeof(*qbuf));
|
||||
*qbuf = (dns_rrl_qname_buf_t){
|
||||
.index = rrl->num_qnames,
|
||||
};
|
||||
ISC_LINK_INIT(qbuf, link);
|
||||
rrl->qnames[rrl->num_qnames++] = qbuf;
|
||||
}
|
||||
if (qbuf != NULL) {
|
||||
e->log_qname = qbuf->index;
|
||||
|
|
|
|||
|
|
@ -1319,14 +1319,13 @@ dns_sdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
|||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
|
||||
sdb = isc_mem_getx(mctx, sizeof(dns_sdb_t), ISC_MEM_ZERO);
|
||||
sdb = isc_mem_get(mctx, sizeof(*sdb));
|
||||
*sdb = (dns_sdb_t){
|
||||
.common = { .methods = &sdb_methods, .rdclass = rdclass },
|
||||
.implementation = imp,
|
||||
};
|
||||
|
||||
dns_name_init(&sdb->common.origin, NULL);
|
||||
sdb->common.attributes = 0;
|
||||
sdb->common.methods = &sdb_methods;
|
||||
sdb->common.rdclass = rdclass;
|
||||
sdb->common.mctx = NULL;
|
||||
sdb->implementation = imp;
|
||||
|
||||
isc_mem_attach(mctx, &sdb->common.mctx);
|
||||
|
||||
|
|
@ -1344,7 +1343,6 @@ dns_sdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
|||
|
||||
sdb->zone = isc_mem_strdup(mctx, zonestr);
|
||||
|
||||
sdb->dbdata = NULL;
|
||||
if (imp->methods->create != NULL) {
|
||||
MAYBE_LOCK(sdb);
|
||||
result = imp->methods->create(sdb->zone, argc, argv,
|
||||
|
|
|
|||
|
|
@ -1454,7 +1454,14 @@ dns_sdlzcreateDBP(isc_mem_t *mctx, void *driverarg, void *dbdata,
|
|||
imp = (dns_sdlzimplementation_t *)driverarg;
|
||||
|
||||
/* allocate and zero memory for driver structure */
|
||||
sdlzdb = isc_mem_getx(mctx, sizeof(dns_sdlz_db_t), ISC_MEM_ZERO);
|
||||
sdlzdb = isc_mem_get(mctx, sizeof(*sdlzdb));
|
||||
|
||||
*sdlzdb = (dns_sdlz_db_t) {
|
||||
.dlzimp = imp,
|
||||
.common = { .methods = &sdlzdb_methods,
|
||||
.rdclass = rdclass, },
|
||||
.dbdata = dbdata,
|
||||
};
|
||||
|
||||
/* initialize and set origin */
|
||||
dns_name_init(&sdlzdb->common.origin, NULL);
|
||||
|
|
@ -1463,13 +1470,6 @@ dns_sdlzcreateDBP(isc_mem_t *mctx, void *driverarg, void *dbdata,
|
|||
goto mem_cleanup;
|
||||
}
|
||||
|
||||
/* set the rest of the database structure attributes */
|
||||
sdlzdb->dlzimp = imp;
|
||||
sdlzdb->common.methods = &sdlzdb_methods;
|
||||
sdlzdb->common.attributes = 0;
|
||||
sdlzdb->common.rdclass = rdclass;
|
||||
sdlzdb->common.mctx = NULL;
|
||||
sdlzdb->dbdata = dbdata;
|
||||
isc_refcount_init(&sdlzdb->references, 1);
|
||||
|
||||
/* attach to the memory context */
|
||||
|
|
@ -1482,7 +1482,7 @@ dns_sdlzcreateDBP(isc_mem_t *mctx, void *driverarg, void *dbdata,
|
|||
|
||||
return (result);
|
||||
mem_cleanup:
|
||||
isc_mem_put(mctx, sdlzdb, sizeof(dns_sdlz_db_t));
|
||||
isc_mem_put(mctx, sdlzdb, sizeof(*sdlzdb));
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
|
@ -1972,14 +1972,14 @@ dns_sdlzregister(const char *drivername, const dns_sdlzmethods_t *methods,
|
|||
* Allocate memory for a sdlz_implementation object. Error if
|
||||
* we cannot.
|
||||
*/
|
||||
imp = isc_mem_getx(mctx, sizeof(dns_sdlzimplementation_t),
|
||||
ISC_MEM_ZERO);
|
||||
imp = isc_mem_get(mctx, sizeof(*imp));
|
||||
|
||||
/* Store the data passed into this method */
|
||||
imp->methods = methods;
|
||||
imp->driverarg = driverarg;
|
||||
imp->flags = flags;
|
||||
imp->mctx = NULL;
|
||||
*imp = (dns_sdlzimplementation_t){
|
||||
.methods = methods,
|
||||
.driverarg = driverarg,
|
||||
.flags = flags,
|
||||
};
|
||||
|
||||
/* attach the new sdlz_implementation object to a memory context */
|
||||
isc_mem_attach(mctx, &imp->mctx);
|
||||
|
|
@ -1990,8 +1990,6 @@ dns_sdlzregister(const char *drivername, const dns_sdlzmethods_t *methods,
|
|||
*/
|
||||
isc_mutex_init(&imp->driverlock);
|
||||
|
||||
imp->dlz_imp = NULL;
|
||||
|
||||
/*
|
||||
* register the DLZ driver. Pass in our "extra" sdlz information as
|
||||
* a driverarg. (that's why we stored the passed in driver arg in our
|
||||
|
|
@ -2018,7 +2016,7 @@ cleanup_mutex:
|
|||
* return the memory back to the available memory pool and
|
||||
* remove it from the memory context.
|
||||
*/
|
||||
isc_mem_putanddetach(&imp->mctx, imp, sizeof(dns_sdlzimplementation_t));
|
||||
isc_mem_putanddetach(&imp->mctx, imp, sizeof(*imp));
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ isc_portset_create(isc_mem_t *mctx, isc_portset_t **portsetp) {
|
|||
|
||||
REQUIRE(portsetp != NULL && *portsetp == NULL);
|
||||
|
||||
portset = isc_mem_getx(mctx, sizeof(*portset), ISC_MEM_ZERO);
|
||||
portset = isc_mem_get(mctx, sizeof(*portset));
|
||||
*portset = (isc_portset_t){ 0 };
|
||||
*portsetp = portset;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -1337,10 +1337,13 @@ isc_tlsctx_cache_add(
|
|||
* The hash table entry does not exist, let's create one.
|
||||
*/
|
||||
INSIST(result != ISC_R_SUCCESS);
|
||||
entry = isc_mem_getx(cache->mctx, sizeof(*entry), ISC_MEM_ZERO);
|
||||
entry = isc_mem_get(cache->mctx, sizeof(*entry));
|
||||
*entry = (isc_tlsctx_cache_entry_t){
|
||||
.ca_store = store,
|
||||
};
|
||||
|
||||
entry->ctx[tr_offset][ipv6] = ctx;
|
||||
entry->client_sess_cache[tr_offset][ipv6] = client_sess_cache;
|
||||
entry->ca_store = store;
|
||||
RUNTIME_CHECK(isc_ht_add(cache->data, (const uint8_t *)name,
|
||||
name_len,
|
||||
(void *)entry) == ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -125,10 +125,12 @@ load_plugin(isc_mem_t *mctx, const char *modpath, ns_plugin_t **pluginp) {
|
|||
|
||||
REQUIRE(pluginp != NULL && *pluginp == NULL);
|
||||
|
||||
plugin = isc_mem_getx(mctx, sizeof(*plugin), ISC_MEM_ZERO);
|
||||
isc_mem_attach(mctx, &plugin->mctx);
|
||||
plugin = isc_mem_get(mctx, sizeof(*plugin));
|
||||
*plugin = (ns_plugin_t){
|
||||
.modpath = isc_mem_strdup(mctx, modpath),
|
||||
};
|
||||
|
||||
plugin->modpath = isc_mem_strdup(plugin->mctx, modpath);
|
||||
isc_mem_attach(mctx, &plugin->mctx);
|
||||
|
||||
ISC_LINK_INIT(plugin, link);
|
||||
|
||||
|
|
@ -317,10 +319,11 @@ ns_hook_add(ns_hooktable_t *hooktable, isc_mem_t *mctx,
|
|||
REQUIRE(hookpoint < NS_HOOKPOINTS_COUNT);
|
||||
REQUIRE(hook != NULL);
|
||||
|
||||
copy = isc_mem_getx(mctx, sizeof(*copy), ISC_MEM_ZERO);
|
||||
|
||||
copy->action = hook->action;
|
||||
copy->action_data = hook->action_data;
|
||||
copy = isc_mem_get(mctx, sizeof(*copy));
|
||||
*copy = (ns_hook_t){
|
||||
.action = hook->action,
|
||||
.action_data = hook->action_data,
|
||||
};
|
||||
isc_mem_attach(mctx, ©->mctx);
|
||||
|
||||
ISC_LINK_INIT(copy, link);
|
||||
|
|
@ -333,7 +336,8 @@ ns_plugins_create(isc_mem_t *mctx, ns_plugins_t **listp) {
|
|||
|
||||
REQUIRE(listp != NULL && *listp == NULL);
|
||||
|
||||
plugins = isc_mem_getx(mctx, sizeof(*plugins), ISC_MEM_ZERO);
|
||||
plugins = isc_mem_get(mctx, sizeof(*plugins));
|
||||
*plugins = (ns_plugins_t){ 0 };
|
||||
ISC_LIST_INIT(*plugins);
|
||||
|
||||
*listp = plugins;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,16 @@ ns_server_create(isc_mem_t *mctx, ns_matchview_t matchingview,
|
|||
|
||||
REQUIRE(sctxp != NULL && *sctxp == NULL);
|
||||
|
||||
sctx = isc_mem_getx(mctx, sizeof(*sctx), ISC_MEM_ZERO);
|
||||
sctx = isc_mem_get(mctx, sizeof(*sctx));
|
||||
*sctx = (ns_server_t){
|
||||
.udpsize = 1232,
|
||||
.transfer_tcp_message_size = 20480,
|
||||
|
||||
.fuzztype = isc_fuzz_none,
|
||||
|
||||
.matchingview = matchingview,
|
||||
.answercookie = true,
|
||||
};
|
||||
|
||||
isc_mem_attach(mctx, &sctx->mctx);
|
||||
|
||||
|
|
@ -89,16 +98,6 @@ ns_server_create(isc_mem_t *mctx, ns_matchview_t matchingview,
|
|||
CHECKFATAL(isc_stats_create(mctx, &sctx->tcpoutstats6,
|
||||
dns_sizecounter_out_max));
|
||||
|
||||
sctx->udpsize = 1232;
|
||||
sctx->transfer_tcp_message_size = 20480;
|
||||
|
||||
sctx->fuzztype = isc_fuzz_none;
|
||||
sctx->fuzznotify = NULL;
|
||||
sctx->gethostname = NULL;
|
||||
|
||||
sctx->matchingview = matchingview;
|
||||
sctx->answercookie = true;
|
||||
|
||||
ISC_LIST_INIT(sctx->altsecrets);
|
||||
|
||||
sctx->magic = SCTX_MAGIC;
|
||||
|
|
|
|||
Loading…
Reference in a new issue