From 89fcb6f897bbaf87f13712d6201b5380afea1a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 23 Aug 2023 08:56:31 +0200 Subject: [PATCH] Apply the isc_mem_cget semantic patch --- bin/dnssec/dnssec-cds.c | 18 ++++---- bin/dnssec/dnssec-signzone.c | 8 ++-- bin/named/config.c | 16 +++---- bin/named/server.c | 2 +- bin/named/zoneconf.c | 14 +++--- bin/nsupdate/nsupdate.c | 25 +++++----- bin/tests/system/dyndb/driver/driver.c | 2 +- lib/dns/acl.c | 14 +++--- lib/dns/diff.c | 4 +- lib/dns/dispatch.c | 36 +++++++-------- lib/dns/dnssec.c | 8 ++-- lib/dns/ipkeylist.c | 64 +++++++++++++------------- lib/dns/journal.c | 20 ++++---- lib/dns/master.c | 8 ++-- lib/dns/rbtdb.c | 18 ++++---- lib/dns/rdataset.c | 8 ++-- lib/dns/rdataslab.c | 22 ++++----- lib/dns/remote.c | 36 +++++++-------- lib/dns/request.c | 4 +- lib/dns/resolver.c | 4 +- lib/dns/ssu.c | 6 +-- lib/dns/zone.c | 15 +++--- lib/dns/zoneverify.c | 4 +- lib/isc/commandline.c | 2 +- lib/isc/heap.c | 8 ++-- lib/isc/include/isc/buffer.h | 4 +- lib/isc/log.c | 5 +- lib/isc/loop.c | 8 ++-- lib/isc/netmgr/http.c | 10 ++-- lib/isc/netmgr/netmgr.c | 12 ++--- lib/isc/netmgr/tlsstream.c | 11 ++--- lib/isc/stats.c | 9 ++-- lib/isc/symtab.c | 12 ++--- lib/isc/tls.c | 6 +-- lib/isccfg/check.c | 2 +- lib/isccfg/parser.c | 8 ++-- lib/ns/client.c | 6 +-- lib/ns/interfacemgr.c | 8 ++-- lib/ns/query.c | 14 +++--- lib/ns/update.c | 7 ++- tests/isc/doh_test.c | 4 +- tests/isc/hashmap_test.c | 16 +++---- tests/isc/mutex_test.c | 4 +- tests/isc/random_test.c | 4 +- tests/isc/rwlock_test.c | 8 ++-- tests/isc/spinlock_test.c | 4 +- 46 files changed, 259 insertions(+), 269 deletions(-) diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index bdb62bf563..2e2d8999f1 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -537,7 +537,7 @@ match_keyset_dsset(dns_rdataset_t *keyset, dns_rdataset_t *dsset, nkey = dns_rdataset_count(keyset); - keytable = isc_mem_getx(mctx, sizeof(keytable[0]) * nkey, ISC_MEM_ZERO); + keytable = isc_mem_cget(mctx, nkey, sizeof(keytable[0])); for (result = dns_rdataset_first(keyset), i = 0, ki = keytable; result == ISC_R_SUCCESS; @@ -593,7 +593,7 @@ free_keytable(keyinfo_t **keytable_p) { } } - isc_mem_put(mctx, keytable, sizeof(keytable[0]) * nkey); + isc_mem_cput(mctx, keytable, nkey, sizeof(keytable[0])); } /* @@ -614,7 +614,7 @@ matching_sigs(keyinfo_t *keytbl, dns_rdataset_t *rdataset, REQUIRE(keytbl != NULL); - algo = isc_mem_getx(mctx, nkey * sizeof(algo[0]), ISC_MEM_ZERO); + algo = isc_mem_cget(mctx, nkey, sizeof(algo[0])); for (result = dns_rdataset_first(sigset); result == ISC_R_SUCCESS; result = dns_rdataset_next(sigset)) @@ -697,7 +697,7 @@ signed_loose(dns_secalg_t *algo) { ok = true; } } - isc_mem_put(mctx, algo, nkey * sizeof(algo[0])); + isc_mem_cput(mctx, algo, nkey, sizeof(algo[0])); return (ok); } @@ -739,7 +739,7 @@ signed_strict(dns_rdataset_t *dsset, dns_secalg_t *algo) { } } - isc_mem_put(mctx, algo, nkey * sizeof(algo[0])); + isc_mem_cput(mctx, algo, nkey, sizeof(algo[0])); return (all_ok); } @@ -894,7 +894,7 @@ consistent_digests(dns_rdataset_t *dsset) { n = dns_rdataset_count(dsset); - arrdata = isc_mem_get(mctx, n * sizeof(dns_rdata_t)); + arrdata = isc_mem_cget(mctx, n, sizeof(dns_rdata_t)); for (result = dns_rdataset_first(dsset), i = 0; result == ISC_R_SUCCESS; result = dns_rdataset_next(dsset), i++) @@ -908,7 +908,7 @@ consistent_digests(dns_rdataset_t *dsset) { /* * Convert sorted arrdata to more accessible format */ - ds = isc_mem_get(mctx, n * sizeof(dns_rdata_ds_t)); + ds = isc_mem_cget(mctx, n, sizeof(dns_rdata_ds_t)); for (i = 0; i < n; i++) { result = dns_rdata_tostruct(&arrdata[i], &ds[i], NULL); @@ -947,8 +947,8 @@ consistent_digests(dns_rdataset_t *dsset) { /* * Done! */ - isc_mem_put(mctx, ds, n * sizeof(dns_rdata_ds_t)); - isc_mem_put(mctx, arrdata, n * sizeof(dns_rdata_t)); + isc_mem_cput(mctx, ds, n, sizeof(dns_rdata_ds_t)); + isc_mem_cput(mctx, arrdata, n, sizeof(dns_rdata_t)); return (match); } diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index c038ab3252..6f6df5406c 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -528,8 +528,8 @@ signset(dns_diff_t *del, dns_diff_t *add, dns_dbnode_t *node, dns_name_t *name, if (!nosigs) { arraysize += dns_rdataset_count(&sigset); } - wassignedby = isc_mem_get(mctx, arraysize * sizeof(bool)); - nowsignedby = isc_mem_get(mctx, arraysize * sizeof(bool)); + wassignedby = isc_mem_cget(mctx, arraysize, sizeof(bool)); + nowsignedby = isc_mem_cget(mctx, arraysize, sizeof(bool)); for (i = 0; i < arraysize; i++) { wassignedby[i] = nowsignedby[i] = false; @@ -781,8 +781,8 @@ signset(dns_diff_t *del, dns_diff_t *add, dns_dbnode_t *node, dns_name_t *name, } } - isc_mem_put(mctx, wassignedby, arraysize * sizeof(bool)); - isc_mem_put(mctx, nowsignedby, arraysize * sizeof(bool)); + isc_mem_cput(mctx, wassignedby, arraysize, sizeof(bool)); + isc_mem_cput(mctx, nowsignedby, arraysize, sizeof(bool)); } struct hashlist { diff --git a/bin/named/config.c b/bin/named/config.c index f6242ebe84..bffd8bdcf3 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -808,10 +808,10 @@ resume: shrink_array(mctx, sources, i, srccount); if (lists != NULL) { - isc_mem_put(mctx, lists, listcount * sizeof(lists[0])); + isc_mem_cput(mctx, lists, listcount, sizeof(lists[0])); } if (stack != NULL) { - isc_mem_put(mctx, stack, stackcount * sizeof(stack[0])); + isc_mem_cput(mctx, stack, stackcount, sizeof(stack[0])); } INSIST(keycount == addrcount); @@ -829,7 +829,7 @@ resume: cleanup: if (addrs != NULL) { - isc_mem_put(mctx, addrs, addrcount * sizeof(addrs[0])); + isc_mem_cput(mctx, addrs, addrcount, sizeof(addrs[0])); } if (keys != NULL) { for (size_t j = 0; j < i; j++) { @@ -841,7 +841,7 @@ cleanup: } isc_mem_put(mctx, keys[j], sizeof(*keys[j])); } - isc_mem_put(mctx, keys, keycount * sizeof(keys[0])); + isc_mem_cput(mctx, keys, keycount, sizeof(keys[0])); } if (tlss != NULL) { for (size_t j = 0; j < i; j++) { @@ -853,16 +853,16 @@ cleanup: } isc_mem_put(mctx, tlss[j], sizeof(*tlss[j])); } - isc_mem_put(mctx, tlss, tlscount * sizeof(tlss[0])); + isc_mem_cput(mctx, tlss, tlscount, sizeof(tlss[0])); } if (sources != NULL) { - isc_mem_put(mctx, sources, srccount * sizeof(sources[0])); + isc_mem_cput(mctx, sources, srccount, sizeof(sources[0])); } if (lists != NULL) { - isc_mem_put(mctx, lists, listcount * sizeof(lists[0])); + isc_mem_cput(mctx, lists, listcount, sizeof(lists[0])); } if (stack != NULL) { - isc_mem_put(mctx, stack, stackcount * sizeof(stack[0])); + isc_mem_cput(mctx, stack, stackcount, sizeof(stack[0])); } return (result); } diff --git a/bin/named/server.c b/bin/named/server.c index d8fb3fb36a..b2ab53b5cf 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -4210,7 +4210,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, dlzargv[0], dlzargc, dlzargv, &dlzdb); isc_mem_free(mctx, s); - isc_mem_put(mctx, dlzargv, dlzargc * sizeof(*dlzargv)); + isc_mem_cput(mctx, dlzargv, dlzargc, sizeof(*dlzargv)); if (result != ISC_R_SUCCESS) { goto cleanup; } diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 35291d47c9..fa34b4c7d4 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -289,7 +289,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone, if (n == 0) { types = NULL; } else { - types = isc_mem_get(mctx, n * sizeof(*types)); + types = isc_mem_cget(mctx, n, sizeof(*types)); } i = 0; @@ -319,8 +319,8 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone, ISC_LOG_ERROR, "'%s' is not a valid count", bracket); - isc_mem_put(mctx, types, - n * sizeof(*types)); + isc_mem_cput(mctx, types, n, + sizeof(*types)); goto cleanup; } } else { @@ -334,7 +334,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone, ISC_LOG_ERROR, "'%.*s' is not a valid type", (int)r.length, str); - isc_mem_put(mctx, types, n * sizeof(*types)); + isc_mem_cput(mctx, types, n, sizeof(*types)); goto cleanup; } } @@ -344,7 +344,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone, mtype, dns_fixedname_name(&fname), n, types); if (types != NULL) { - isc_mem_put(mctx, types, n * sizeof(*types)); + isc_mem_cput(mctx, types, n, sizeof(*types)); } } @@ -705,7 +705,7 @@ strtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp, if (*s == '\0') { /* We have reached the end of the string. */ *argcp = n; - *argvp = isc_mem_get(mctx, n * sizeof(char *)); + *argvp = isc_mem_cget(mctx, n, sizeof(char *)); } else { char *p = s; while (*p != ' ' && *p != '\t' && *p != '\0') { @@ -1000,7 +1000,7 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, * compiler w/o generating a warning. */ dns_zone_setdbtype(zone, dbargc, (const char *const *)dbargv); - isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv)); + isc_mem_cput(mctx, dbargv, dbargc, sizeof(*dbargv)); if (cpval != default_dbtype && cpval != dlz_dbtype) { isc_mem_free(mctx, cpval); } diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 05d60a2f47..47ff134f3a 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -238,8 +238,8 @@ error(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); static void primary_from_servers(void) { if (primary_servers != NULL && primary_servers != servers) { - isc_mem_put(gmctx, primary_servers, - primary_alloc * sizeof(isc_sockaddr_t)); + isc_mem_cput(gmctx, primary_servers, primary_alloc, + sizeof(isc_sockaddr_t)); } primary_servers = servers; primary_total = ns_total; @@ -684,12 +684,12 @@ doshutdown(void) { * to NULL. */ if (primary_servers != NULL && primary_servers != servers) { - isc_mem_put(gmctx, primary_servers, - primary_alloc * sizeof(isc_sockaddr_t)); + isc_mem_cput(gmctx, primary_servers, primary_alloc, + sizeof(isc_sockaddr_t)); } if (servers != NULL) { - isc_mem_put(gmctx, servers, ns_alloc * sizeof(isc_sockaddr_t)); + isc_mem_cput(gmctx, servers, ns_alloc, sizeof(isc_sockaddr_t)); } if (localaddr4 != NULL) { @@ -830,7 +830,7 @@ setup_system(void) { if (primary_servers == servers) { primary_servers = NULL; } - isc_mem_put(gmctx, servers, ns_alloc * sizeof(isc_sockaddr_t)); + isc_mem_cput(gmctx, servers, ns_alloc, sizeof(isc_sockaddr_t)); } ns_inuse = 0; @@ -845,7 +845,7 @@ setup_system(void) { default_servers = !local_only; ns_total = ns_alloc = (have_ipv4 ? 1 : 0) + (have_ipv6 ? 1 : 0); - servers = isc_mem_get(gmctx, ns_alloc * sizeof(isc_sockaddr_t)); + servers = isc_mem_cget(gmctx, ns_alloc, sizeof(isc_sockaddr_t)); if (have_ipv6) { memset(&in6, 0, sizeof(in6)); @@ -887,7 +887,7 @@ setup_system(void) { } ns_alloc = ns_total; - servers = isc_mem_get(gmctx, ns_alloc * sizeof(isc_sockaddr_t)); + servers = isc_mem_cget(gmctx, ns_alloc, sizeof(isc_sockaddr_t)); i = 0; for (sa = ISC_LIST_HEAD(*nslist); sa != NULL; @@ -1556,15 +1556,14 @@ evaluate_server(char *cmdline) { if (primary_servers == servers) { primary_servers = NULL; } - isc_mem_put(gmctx, servers, ns_alloc * sizeof(isc_sockaddr_t)); + isc_mem_cput(gmctx, servers, ns_alloc, sizeof(isc_sockaddr_t)); } default_servers = false; ns_alloc = MAX_SERVERADDRS; ns_inuse = 0; - servers = isc_mem_getx(gmctx, ns_alloc * sizeof(isc_sockaddr_t), - ISC_MEM_ZERO); + servers = isc_mem_cget(gmctx, ns_alloc, sizeof(isc_sockaddr_t)); ns_total = get_addresses(server, (in_port_t)port, servers, ns_alloc); if (ns_total == 0) { return (STATUS_SYNTAX); @@ -2832,8 +2831,8 @@ lookforsoa: serverstr[isc_buffer_usedlength(&buf)] = 0; if (primary_servers != NULL && primary_servers != servers) { - isc_mem_put(gmctx, primary_servers, - primary_alloc * sizeof(isc_sockaddr_t)); + isc_mem_cput(gmctx, primary_servers, primary_alloc, + sizeof(isc_sockaddr_t)); } primary_alloc = MAX_SERVERADDRS; size = primary_alloc * sizeof(isc_sockaddr_t); diff --git a/bin/tests/system/dyndb/driver/driver.c b/bin/tests/system/dyndb/driver/driver.c index 7e8a249d3a..33702bd9e8 100644 --- a/bin/tests/system/dyndb/driver/driver.c +++ b/bin/tests/system/dyndb/driver/driver.c @@ -135,7 +135,7 @@ dyndb_init(isc_mem_t *mctx, const char *name, const char *parameters, cleanup: isc_mem_free(mctx, s); if (argv != NULL) { - isc_mem_put(mctx, argv, argc * sizeof(*argv)); + isc_mem_cput(mctx, argv, argc, sizeof(*argv)); } return (result); diff --git a/lib/dns/acl.c b/lib/dns/acl.c index 8678490906..8dacc2aa2d 100644 --- a/lib/dns/acl.c +++ b/lib/dns/acl.c @@ -70,8 +70,7 @@ dns_acl_create(isc_mem_t *mctx, int n, dns_acl_t **target) { */ acl->magic = DNS_ACL_MAGIC; - acl->elements = isc_mem_getx(mctx, n * sizeof(acl->elements[0]), - ISC_MEM_ZERO); + acl->elements = isc_mem_cget(mctx, n, sizeof(acl->elements[0])); acl->alloc = n; ISC_LIST_INIT(acl->ports_and_transports); acl->port_proto_entries = 0; @@ -316,10 +315,9 @@ dns_acl_merge(dns_acl_t *dest, dns_acl_t *source, bool pos) { newalloc = 4; } - dest->elements = isc_mem_regetx( - dest->mctx, dest->elements, - dest->alloc * sizeof(dest->elements[0]), - newalloc * sizeof(dest->elements[0]), ISC_MEM_ZERO); + dest->elements = isc_mem_creget(dest->mctx, dest->elements, + dest->alloc, newalloc, + sizeof(dest->elements[0])); dest->alloc = newalloc; } @@ -521,8 +519,8 @@ destroy(dns_acl_t *dacl) { } } if (dacl->elements != NULL) { - isc_mem_put(dacl->mctx, dacl->elements, - dacl->alloc * sizeof(dacl->elements[0])); + isc_mem_cput(dacl->mctx, dacl->elements, dacl->alloc, + sizeof(dacl->elements[0])); } if (dacl->name != NULL) { isc_mem_free(dacl->mctx, dacl->name); diff --git a/lib/dns/diff.c b/lib/dns/diff.c index 8f900ab26a..e4bfceefa8 100644 --- a/lib/dns/diff.c +++ b/lib/dns/diff.c @@ -560,7 +560,7 @@ dns_diff_sort(dns_diff_t *diff, dns_diff_compare_func *compare) { if (length == 0) { return (ISC_R_SUCCESS); } - v = isc_mem_get(diff->mctx, length * sizeof(dns_difftuple_t *)); + v = isc_mem_cget(diff->mctx, length, sizeof(dns_difftuple_t *)); for (i = 0; i < length; i++) { p = ISC_LIST_HEAD(diff->tuples); v[i] = p; @@ -571,7 +571,7 @@ dns_diff_sort(dns_diff_t *diff, dns_diff_compare_func *compare) { for (i = 0; i < length; i++) { ISC_LIST_APPEND(diff->tuples, v[i], link); } - isc_mem_put(diff->mctx, v, length * sizeof(dns_difftuple_t *)); + isc_mem_cput(diff->mctx, v, length, sizeof(dns_difftuple_t *)); return (ISC_R_SUCCESS); } diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 6b222eab60..d79614522e 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -953,11 +953,11 @@ setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset, v4ports = NULL; if (nv4ports != 0) { - v4ports = isc_mem_get(mgr->mctx, sizeof(in_port_t) * nv4ports); + v4ports = isc_mem_cget(mgr->mctx, nv4ports, sizeof(in_port_t)); } v6ports = NULL; if (nv6ports != 0) { - v6ports = isc_mem_get(mgr->mctx, sizeof(in_port_t) * nv6ports); + v6ports = isc_mem_cget(mgr->mctx, nv6ports, sizeof(in_port_t)); } do { @@ -973,15 +973,15 @@ setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset, INSIST(i4 == nv4ports && i6 == nv6ports); if (mgr->v4ports != NULL) { - isc_mem_put(mgr->mctx, mgr->v4ports, - mgr->nv4ports * sizeof(in_port_t)); + isc_mem_cput(mgr->mctx, mgr->v4ports, mgr->nv4ports, + sizeof(in_port_t)); } mgr->v4ports = v4ports; mgr->nv4ports = nv4ports; if (mgr->v6ports != NULL) { - isc_mem_put(mgr->mctx, mgr->v6ports, - mgr->nv6ports * sizeof(in_port_t)); + isc_mem_cput(mgr->mctx, mgr->v6ports, mgr->nv6ports, + sizeof(in_port_t)); } mgr->v6ports = v6ports; mgr->nv6ports = nv6ports; @@ -1082,12 +1082,12 @@ dispatchmgr_destroy(dns_dispatchmgr_t *mgr) { } if (mgr->v4ports != NULL) { - isc_mem_put(mgr->mctx, mgr->v4ports, - mgr->nv4ports * sizeof(in_port_t)); + isc_mem_cput(mgr->mctx, mgr->v4ports, mgr->nv4ports, + sizeof(in_port_t)); } if (mgr->v6ports != NULL) { - isc_mem_put(mgr->mctx, mgr->v6ports, - mgr->nv6ports * sizeof(in_port_t)); + isc_mem_cput(mgr->mctx, mgr->v6ports, mgr->nv6ports, + sizeof(in_port_t)); } isc_nm_detach(&mgr->nm); @@ -1115,8 +1115,8 @@ qid_allocate(dns_dispatchmgr_t *mgr, dns_qid_t **qidp) { *qid = (dns_qid_t){ .qid_nbuckets = DNS_QID_BUCKETS, .qid_increment = DNS_QID_INCREMENT }; - qid->qid_table = isc_mem_get(mgr->mctx, - DNS_QID_BUCKETS * sizeof(dns_displist_t)); + qid->qid_table = isc_mem_cget(mgr->mctx, DNS_QID_BUCKETS, + sizeof(dns_displist_t)); for (i = 0; i < qid->qid_nbuckets; i++) { ISC_LIST_INIT(qid->qid_table[i]); } @@ -1137,8 +1137,8 @@ qid_destroy(isc_mem_t *mctx, dns_qid_t **qidp) { REQUIRE(VALID_QID(qid)); qid->magic = 0; - isc_mem_put(mctx, qid->qid_table, - qid->qid_nbuckets * sizeof(dns_displist_t)); + isc_mem_cput(mctx, qid->qid_table, qid->qid_nbuckets, + sizeof(dns_displist_t)); isc_mutex_destroy(&qid->lock); isc_mem_put(mctx, qid, sizeof(*qid)); } @@ -2290,7 +2290,7 @@ dns_dispatchset_create(isc_mem_t *mctx, dns_dispatch_t *source, isc_mutex_init(&dset->lock); - dset->dispatches = isc_mem_get(mctx, sizeof(dns_dispatch_t *) * n); + dset->dispatches = isc_mem_cget(mctx, n, sizeof(dns_dispatch_t *)); isc_mem_attach(mctx, &dset->mctx); @@ -2318,7 +2318,7 @@ fail: for (j = 0; j < i; j++) { dns_dispatch_detach(&(dset->dispatches[j])); /* DISPATCH004 */ } - isc_mem_put(mctx, dset->dispatches, sizeof(dns_dispatch_t *) * n); + isc_mem_cput(mctx, dset->dispatches, n, sizeof(dns_dispatch_t *)); if (dset->mctx == mctx) { isc_mem_detach(&dset->mctx); } @@ -2340,8 +2340,8 @@ dns_dispatchset_destroy(dns_dispatchset_t **dsetp) { for (i = 0; i < dset->ndisp; i++) { dns_dispatch_detach(&(dset->dispatches[i])); /* DISPATCH004 */ } - isc_mem_put(dset->mctx, dset->dispatches, - sizeof(dns_dispatch_t *) * dset->ndisp); + isc_mem_cput(dset->mctx, dset->dispatches, dset->ndisp, + sizeof(dns_dispatch_t *)); isc_mutex_destroy(&dset->lock); isc_mem_putanddetach(&dset->mctx, dset, sizeof(dns_dispatchset_t)); } diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index 8240080a8e..92ac096134 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -101,14 +101,14 @@ rdataset_to_sortedarray(dns_rdataset_t *set, isc_mem_t *mctx, n = dns_rdataset_count(set); - data = isc_mem_get(mctx, n * sizeof(dns_rdata_t)); + data = isc_mem_cget(mctx, n, sizeof(dns_rdata_t)); dns_rdataset_init(&rdataset); dns_rdataset_clone(set, &rdataset); ret = dns_rdataset_first(&rdataset); if (ret != ISC_R_SUCCESS) { dns_rdataset_disassociate(&rdataset); - isc_mem_put(mctx, data, n * sizeof(dns_rdata_t)); + isc_mem_cput(mctx, data, n, sizeof(dns_rdata_t)); return (ret); } @@ -359,7 +359,7 @@ dns_dnssec_sign(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, sig.common.rdtype, &sig, buffer); cleanup_array: - isc_mem_put(mctx, rdatas, nrdatas * sizeof(dns_rdata_t)); + isc_mem_cput(mctx, rdatas, nrdatas, sizeof(dns_rdata_t)); cleanup_context: dst_context_destroy(&ctx); cleanup_databuf: @@ -573,7 +573,7 @@ again: } cleanup_array: - isc_mem_put(mctx, rdatas, nrdatas * sizeof(dns_rdata_t)); + isc_mem_cput(mctx, rdatas, nrdatas, sizeof(dns_rdata_t)); cleanup_context: dst_context_destroy(&ctx); if (ret == DST_R_VERIFYFAILURE && !downcase) { diff --git a/lib/dns/ipkeylist.c b/lib/dns/ipkeylist.c index 068a90cc1f..d4e2869f42 100644 --- a/lib/dns/ipkeylist.c +++ b/lib/dns/ipkeylist.c @@ -43,18 +43,18 @@ dns_ipkeylist_clear(isc_mem_t *mctx, dns_ipkeylist_t *ipkl) { } if (ipkl->addrs != NULL) { - isc_mem_put(mctx, ipkl->addrs, - ipkl->allocated * sizeof(isc_sockaddr_t)); + isc_mem_cput(mctx, ipkl->addrs, ipkl->allocated, + sizeof(isc_sockaddr_t)); } if (ipkl->sources != NULL) { - isc_mem_put(mctx, ipkl->sources, - ipkl->allocated * sizeof(isc_sockaddr_t)); + isc_mem_cput(mctx, ipkl->sources, ipkl->allocated, + sizeof(isc_sockaddr_t)); } if (ipkl->addrs != NULL) { - isc_mem_put(mctx, ipkl->addrs, - ipkl->allocated * sizeof(isc_sockaddr_t)); + isc_mem_cput(mctx, ipkl->addrs, ipkl->allocated, + sizeof(isc_sockaddr_t)); } if (ipkl->keys != NULL) { @@ -67,8 +67,8 @@ dns_ipkeylist_clear(isc_mem_t *mctx, dns_ipkeylist_t *ipkl) { } isc_mem_put(mctx, ipkl->keys[i], sizeof(dns_name_t)); } - isc_mem_put(mctx, ipkl->keys, - ipkl->allocated * sizeof(dns_name_t *)); + isc_mem_cput(mctx, ipkl->keys, ipkl->allocated, + sizeof(dns_name_t *)); } if (ipkl->tlss != NULL) { @@ -81,8 +81,8 @@ dns_ipkeylist_clear(isc_mem_t *mctx, dns_ipkeylist_t *ipkl) { } isc_mem_put(mctx, ipkl->tlss[i], sizeof(dns_name_t)); } - isc_mem_put(mctx, ipkl->tlss, - ipkl->allocated * sizeof(dns_name_t *)); + isc_mem_cput(mctx, ipkl->tlss, ipkl->allocated, + sizeof(dns_name_t *)); } if (ipkl->labels != NULL) { @@ -95,8 +95,8 @@ dns_ipkeylist_clear(isc_mem_t *mctx, dns_ipkeylist_t *ipkl) { } isc_mem_put(mctx, ipkl->labels[i], sizeof(dns_name_t)); } - isc_mem_put(mctx, ipkl->labels, - ipkl->allocated * sizeof(dns_name_t *)); + isc_mem_cput(mctx, ipkl->labels, ipkl->allocated, + sizeof(dns_name_t *)); } dns_ipkeylist_init(ipkl); @@ -186,17 +186,17 @@ dns_ipkeylist_resize(isc_mem_t *mctx, dns_ipkeylist_t *ipkl, unsigned int n) { return (ISC_R_SUCCESS); } - addrs = isc_mem_get(mctx, n * sizeof(isc_sockaddr_t)); - sources = isc_mem_get(mctx, n * sizeof(isc_sockaddr_t)); - keys = isc_mem_get(mctx, n * sizeof(dns_name_t *)); - tlss = isc_mem_get(mctx, n * sizeof(dns_name_t *)); - labels = isc_mem_get(mctx, n * sizeof(dns_name_t *)); + addrs = isc_mem_cget(mctx, n, sizeof(isc_sockaddr_t)); + sources = isc_mem_cget(mctx, n, sizeof(isc_sockaddr_t)); + keys = isc_mem_cget(mctx, n, sizeof(dns_name_t *)); + tlss = isc_mem_cget(mctx, n, sizeof(dns_name_t *)); + labels = isc_mem_cget(mctx, n, sizeof(dns_name_t *)); if (ipkl->addrs != NULL) { memmove(addrs, ipkl->addrs, ipkl->allocated * sizeof(isc_sockaddr_t)); - isc_mem_put(mctx, ipkl->addrs, - ipkl->allocated * sizeof(isc_sockaddr_t)); + isc_mem_cput(mctx, ipkl->addrs, ipkl->allocated, + sizeof(isc_sockaddr_t)); } ipkl->addrs = addrs; memset(&ipkl->addrs[ipkl->allocated], 0, @@ -205,8 +205,8 @@ dns_ipkeylist_resize(isc_mem_t *mctx, dns_ipkeylist_t *ipkl, unsigned int n) { if (ipkl->sources != NULL) { memmove(sources, ipkl->sources, ipkl->allocated * sizeof(isc_sockaddr_t)); - isc_mem_put(mctx, ipkl->sources, - ipkl->allocated * sizeof(isc_sockaddr_t)); + isc_mem_cput(mctx, ipkl->sources, ipkl->allocated, + sizeof(isc_sockaddr_t)); } ipkl->sources = sources; memset(&ipkl->sources[ipkl->allocated], 0, @@ -215,8 +215,8 @@ dns_ipkeylist_resize(isc_mem_t *mctx, dns_ipkeylist_t *ipkl, unsigned int n) { if (ipkl->keys) { memmove(keys, ipkl->keys, ipkl->allocated * sizeof(dns_name_t *)); - isc_mem_put(mctx, ipkl->keys, - ipkl->allocated * sizeof(dns_name_t *)); + isc_mem_cput(mctx, ipkl->keys, ipkl->allocated, + sizeof(dns_name_t *)); } ipkl->keys = keys; memset(&ipkl->keys[ipkl->allocated], 0, @@ -225,8 +225,8 @@ dns_ipkeylist_resize(isc_mem_t *mctx, dns_ipkeylist_t *ipkl, unsigned int n) { if (ipkl->tlss) { memmove(tlss, ipkl->tlss, ipkl->allocated * sizeof(dns_name_t *)); - isc_mem_put(mctx, ipkl->tlss, - ipkl->allocated * sizeof(dns_name_t *)); + isc_mem_cput(mctx, ipkl->tlss, ipkl->allocated, + sizeof(dns_name_t *)); } ipkl->tlss = tlss; memset(&ipkl->tlss[ipkl->allocated], 0, @@ -235,8 +235,8 @@ dns_ipkeylist_resize(isc_mem_t *mctx, dns_ipkeylist_t *ipkl, unsigned int n) { if (ipkl->labels != NULL) { memmove(labels, ipkl->labels, ipkl->allocated * sizeof(dns_name_t *)); - isc_mem_put(mctx, ipkl->labels, - ipkl->allocated * sizeof(dns_name_t *)); + isc_mem_cput(mctx, ipkl->labels, ipkl->allocated, + sizeof(dns_name_t *)); } ipkl->labels = labels; memset(&ipkl->labels[ipkl->allocated], 0, @@ -245,11 +245,11 @@ dns_ipkeylist_resize(isc_mem_t *mctx, dns_ipkeylist_t *ipkl, unsigned int n) { ipkl->allocated = n; return (ISC_R_SUCCESS); - isc_mem_put(mctx, addrs, n * sizeof(isc_sockaddr_t)); - isc_mem_put(mctx, sources, n * sizeof(isc_sockaddr_t)); - isc_mem_put(mctx, tlss, n * sizeof(dns_name_t *)); - isc_mem_put(mctx, keys, n * sizeof(dns_name_t *)); - isc_mem_put(mctx, labels, n * sizeof(dns_name_t *)); + isc_mem_cput(mctx, addrs, n, sizeof(isc_sockaddr_t)); + isc_mem_cput(mctx, sources, n, sizeof(isc_sockaddr_t)); + isc_mem_cput(mctx, tlss, n, sizeof(dns_name_t *)); + isc_mem_cput(mctx, keys, n, sizeof(dns_name_t *)); + isc_mem_cput(mctx, labels, n, sizeof(dns_name_t *)); return (ISC_R_NOMEMORY); } diff --git a/lib/dns/journal.c b/lib/dns/journal.c index bb23a648bc..7961c667cb 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -709,8 +709,8 @@ journal_open(isc_mem_t *mctx, const char *filename, bool writable, bool create, CHECK(journal_read(j, j->rawindex, rawbytes)); - j->index = isc_mem_get(mctx, j->header.index_size * - sizeof(journal_pos_t)); + j->index = isc_mem_cget(mctx, j->header.index_size, + sizeof(journal_pos_t)); p = j->rawindex; for (i = 0; i < j->header.index_size; i++) { @@ -746,12 +746,12 @@ journal_open(isc_mem_t *mctx, const char *filename, bool writable, bool create, failure: j->magic = 0; if (j->rawindex != NULL) { - isc_mem_put(j->mctx, j->rawindex, - j->header.index_size * sizeof(journal_rawpos_t)); + isc_mem_cput(j->mctx, j->rawindex, j->header.index_size, + sizeof(journal_rawpos_t)); } if (j->index != NULL) { - isc_mem_put(j->mctx, j->index, - j->header.index_size * sizeof(journal_pos_t)); + isc_mem_cput(j->mctx, j->index, j->header.index_size, + sizeof(journal_pos_t)); } isc_mem_free(j->mctx, j->filename); if (j->fp != NULL) { @@ -1443,12 +1443,12 @@ dns_journal_destroy(dns_journal_t **journalp) { j->it.result = ISC_R_FAILURE; dns_name_invalidate(&j->it.name); if (j->rawindex != NULL) { - isc_mem_put(j->mctx, j->rawindex, - j->header.index_size * sizeof(journal_rawpos_t)); + isc_mem_cput(j->mctx, j->rawindex, j->header.index_size, + sizeof(journal_rawpos_t)); } if (j->index != NULL) { - isc_mem_put(j->mctx, j->index, - j->header.index_size * sizeof(journal_pos_t)); + isc_mem_cput(j->mctx, j->index, j->header.index_size, + sizeof(journal_pos_t)); } if (j->it.target.base != NULL) { isc_mem_put(j->mctx, j->it.target.base, j->it.target.length); diff --git a/lib/dns/master.c b/lib/dns/master.c index 1d6aa5078e..8d1b966a29 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -2123,11 +2123,11 @@ cleanup: ISC_LIST_UNLINK(glue_list, this, link); } if (rdatalist != NULL) { - isc_mem_put(mctx, rdatalist, - rdatalist_size * sizeof(*rdatalist)); + isc_mem_cput(mctx, rdatalist, rdatalist_size, + sizeof(*rdatalist)); } if (rdata != NULL) { - isc_mem_put(mctx, rdata, rdata_size * sizeof(*rdata)); + isc_mem_cput(mctx, rdata, rdata_size, sizeof(*rdata)); } if (target_mem != NULL) { isc_mem_put(mctx, target_mem, target_size); @@ -2599,7 +2599,7 @@ load_raw(dns_loadctx_t *lctx) { cleanup: if (rdata != NULL) { - isc_mem_put(mctx, rdata, rdata_size * sizeof(*rdata)); + isc_mem_cput(mctx, rdata, rdata_size, sizeof(*rdata)); } if (target_mem != NULL) { isc_mem_put(mctx, target_mem, target_size); diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 4728ff90d9..78464170b0 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -530,9 +530,9 @@ free_rbtdb(dns_rbtdb_t *rbtdb, bool log) { for (i = 0; i < rbtdb->node_lock_count; i++) { INSIST(ISC_LIST_EMPTY(rbtdb->lru[i])); } - isc_mem_put(rbtdb->common.mctx, rbtdb->lru, - rbtdb->node_lock_count * - sizeof(dns_slabheaderlist_t)); + isc_mem_cput(rbtdb->common.mctx, rbtdb->lru, + rbtdb->node_lock_count, + sizeof(dns_slabheaderlist_t)); } /* * Clean up dead node buckets. @@ -541,8 +541,8 @@ free_rbtdb(dns_rbtdb_t *rbtdb, bool log) { for (i = 0; i < rbtdb->node_lock_count; i++) { INSIST(ISC_LIST_EMPTY(rbtdb->deadnodes[i])); } - isc_mem_put(rbtdb->common.mctx, rbtdb->deadnodes, - rbtdb->node_lock_count * sizeof(dns_rbtnodelist_t)); + isc_mem_cput(rbtdb->common.mctx, rbtdb->deadnodes, + rbtdb->node_lock_count, sizeof(dns_rbtnodelist_t)); } /* * Clean up heap objects. @@ -551,8 +551,8 @@ free_rbtdb(dns_rbtdb_t *rbtdb, bool log) { for (i = 0; i < rbtdb->node_lock_count; i++) { isc_heap_destroy(&rbtdb->heaps[i]); } - isc_mem_put(rbtdb->hmctx, rbtdb->heaps, - rbtdb->node_lock_count * sizeof(isc_heap_t *)); + isc_mem_cput(rbtdb->hmctx, rbtdb->heaps, rbtdb->node_lock_count, + sizeof(isc_heap_t *)); } if (rbtdb->rrsetstats != NULL) { @@ -565,8 +565,8 @@ free_rbtdb(dns_rbtdb_t *rbtdb, bool log) { isc_stats_detach(&rbtdb->gluecachestats); } - isc_mem_put(rbtdb->common.mctx, rbtdb->node_locks, - rbtdb->node_lock_count * sizeof(rbtdb_nodelock_t)); + isc_mem_cput(rbtdb->common.mctx, rbtdb->node_locks, + rbtdb->node_lock_count, sizeof(rbtdb_nodelock_t)); TREE_DESTROYLOCK(&rbtdb->tree_lock); isc_refcount_destroy(&rbtdb->common.references); if (rbtdb->loop != NULL) { diff --git a/lib/dns/rdataset.c b/lib/dns/rdataset.c index f179893fa5..deccd7ed9c 100644 --- a/lib/dns/rdataset.c +++ b/lib/dns/rdataset.c @@ -310,8 +310,8 @@ towiresorted(dns_rdataset_t *rdataset, const dns_name_t *owner_name, if ((shuffle || sort)) { if (count > MAX_SHUFFLE) { - in = isc_mem_get(cctx->mctx, count * sizeof(*in)); - out = isc_mem_get(cctx->mctx, count * sizeof(*out)); + in = isc_mem_cget(cctx->mctx, count, sizeof(*in)); + out = isc_mem_cget(cctx->mctx, count, sizeof(*out)); if (in == NULL || out == NULL) { shuffle = sort = false; } @@ -467,10 +467,10 @@ rollback: cleanup: if (out != NULL && out != out_fixed) { - isc_mem_put(cctx->mctx, out, count * sizeof(*out)); + isc_mem_cput(cctx->mctx, out, count, sizeof(*out)); } if (in != NULL && in != in_fixed) { - isc_mem_put(cctx->mctx, in, count * sizeof(*in)); + isc_mem_cput(cctx->mctx, in, count, sizeof(*in)); } return (result); } diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c index 647a99fef1..bc439359b2 100644 --- a/lib/dns/rdataslab.c +++ b/lib/dns/rdataslab.c @@ -224,7 +224,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, * Remember the original number of items. */ nalloc = nitems; - x = isc_mem_get(mctx, nalloc * sizeof(struct xrdata)); + x = isc_mem_cget(mctx, nalloc, sizeof(struct xrdata)); /* * Save all of the rdata members into an array. @@ -333,8 +333,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, #if DNS_RDATASET_FIXED /* Allocate temporary offset table. */ - offsettable = isc_mem_getx(mctx, nalloc * sizeof(unsigned int), - ISC_MEM_ZERO); + offsettable = isc_mem_cget(mctx, nalloc, sizeof(unsigned int)); #endif /* if DNS_RDATASET_FIXED */ region->base = rawbuf; @@ -385,13 +384,13 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, #if DNS_RDATASET_FIXED fillin_offsets(offsetbase, offsettable, nalloc); - isc_mem_put(mctx, offsettable, nalloc * sizeof(unsigned int)); + isc_mem_cput(mctx, offsettable, nalloc, sizeof(unsigned int)); #endif /* if DNS_RDATASET_FIXED */ result = ISC_R_SUCCESS; free_rdatas: - isc_mem_put(mctx, x, nalloc * sizeof(struct xrdata)); + isc_mem_cput(mctx, x, nalloc, sizeof(struct xrdata)); return (result); } @@ -685,8 +684,8 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab, */ tcurrent += (tcount * 4); - offsettable = isc_mem_getx( - mctx, (ocount + oncount) * sizeof(unsigned int), ISC_MEM_ZERO); + offsettable = isc_mem_cget(mctx, (ocount + oncount), + sizeof(unsigned int)); #endif /* if DNS_RDATASET_FIXED */ /* @@ -791,8 +790,8 @@ dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab, #if DNS_RDATASET_FIXED fillin_offsets(offsetbase, offsettable, ocount + oncount); - isc_mem_put(mctx, offsettable, - (ocount + oncount) * sizeof(unsigned int)); + isc_mem_cput(mctx, offsettable, (ocount + oncount), + sizeof(unsigned int)); #endif /* if DNS_RDATASET_FIXED */ INSIST(tcurrent == tstart + tlength); @@ -909,8 +908,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab, #if DNS_RDATASET_FIXED offsetbase = tcurrent; - offsettable = isc_mem_getx(mctx, mcount * sizeof(unsigned int), - ISC_MEM_ZERO); + offsettable = isc_mem_cget(mctx, mcount, sizeof(unsigned int)); #endif /* if DNS_RDATASET_FIXED */ /* @@ -966,7 +964,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab, #if DNS_RDATASET_FIXED fillin_offsets(offsetbase, offsettable, mcount); - isc_mem_put(mctx, offsettable, mcount * sizeof(unsigned int)); + isc_mem_cput(mctx, offsettable, mcount, sizeof(unsigned int)); #endif /* if DNS_RDATASET_FIXED */ INSIST(tcurrent == tstart + tlength); diff --git a/lib/dns/remote.c b/lib/dns/remote.c index 38175b0ae3..7c44904ea4 100644 --- a/lib/dns/remote.c +++ b/lib/dns/remote.c @@ -72,8 +72,8 @@ dns_remote_init(dns_remote_t *remote, unsigned int count, remote->mctx = mctx; if (addrs != NULL) { - remote->addresses = isc_mem_get(mctx, - count * sizeof(isc_sockaddr_t)); + remote->addresses = isc_mem_cget(mctx, count, + sizeof(isc_sockaddr_t)); memmove(remote->addresses, addrs, count * sizeof(isc_sockaddr_t)); } else { @@ -81,16 +81,16 @@ dns_remote_init(dns_remote_t *remote, unsigned int count, } if (srcs != NULL) { - remote->sources = isc_mem_get(mctx, - count * sizeof(isc_sockaddr_t)); + remote->sources = isc_mem_cget(mctx, count, + sizeof(isc_sockaddr_t)); memmove(remote->sources, srcs, count * sizeof(isc_sockaddr_t)); } else { remote->sources = NULL; } if (keynames != NULL) { - remote->keynames = isc_mem_get(mctx, - count * sizeof(keynames[0])); + remote->keynames = isc_mem_cget(mctx, count, + sizeof(keynames[0])); for (i = 0; i < count; i++) { remote->keynames[i] = NULL; } @@ -108,8 +108,8 @@ dns_remote_init(dns_remote_t *remote, unsigned int count, } if (tlsnames != NULL) { - remote->tlsnames = isc_mem_get(mctx, - count * sizeof(tlsnames[0])); + remote->tlsnames = isc_mem_cget(mctx, count, + sizeof(tlsnames[0])); for (i = 0; i < count; i++) { remote->tlsnames[i] = NULL; } @@ -127,7 +127,7 @@ dns_remote_init(dns_remote_t *remote, unsigned int count, } if (mark) { - remote->ok = isc_mem_get(mctx, count * sizeof(bool)); + remote->ok = isc_mem_cget(mctx, count, sizeof(bool)); for (i = 0; i < count; i++) { remote->ok[i] = false; } @@ -199,19 +199,19 @@ dns_remote_clear(dns_remote_t *remote) { } if (remote->ok != NULL) { - isc_mem_put(mctx, remote->ok, count * sizeof(bool)); + isc_mem_cput(mctx, remote->ok, count, sizeof(bool)); remote->ok = NULL; } if (remote->addresses != NULL) { - isc_mem_put(mctx, remote->addresses, - count * sizeof(isc_sockaddr_t)); + isc_mem_cput(mctx, remote->addresses, count, + sizeof(isc_sockaddr_t)); remote->addresses = NULL; } if (remote->sources != NULL) { - isc_mem_put(mctx, remote->sources, - count * sizeof(isc_sockaddr_t)); + isc_mem_cput(mctx, remote->sources, count, + sizeof(isc_sockaddr_t)); remote->sources = NULL; } @@ -225,8 +225,8 @@ dns_remote_clear(dns_remote_t *remote) { remote->keynames[i] = NULL; } } - isc_mem_put(mctx, remote->keynames, - count * sizeof(dns_name_t *)); + isc_mem_cput(mctx, remote->keynames, count, + sizeof(dns_name_t *)); remote->keynames = NULL; } @@ -240,8 +240,8 @@ dns_remote_clear(dns_remote_t *remote) { remote->tlsnames[i] = NULL; } } - isc_mem_put(mctx, remote->tlsnames, - count * sizeof(dns_name_t *)); + isc_mem_cput(mctx, remote->tlsnames, count, + sizeof(dns_name_t *)); remote->tlsnames = NULL; } diff --git a/lib/dns/request.c b/lib/dns/request.c index f675fb495f..5abc1c5f40 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -230,8 +230,8 @@ requestmgr_destroy(dns_requestmgr_t *requestmgr) { for (size_t i = 0; i < nloops; i++) { INSIST(ISC_LIST_EMPTY(requestmgr->requests[i])); } - isc_mem_put(requestmgr->mctx, requestmgr->requests, - nloops * sizeof(requestmgr->requests[0])); + isc_mem_cput(requestmgr->mctx, requestmgr->requests, nloops, + sizeof(requestmgr->requests[0])); if (requestmgr->dispatchv4 != NULL) { dns_dispatch_detach(&requestmgr->dispatchv4); diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 481e318367..8955ca2c0b 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -10797,8 +10797,8 @@ dns_resolver_disable_algorithm(dns_resolver_t *resolver, const dns_name_t *name, * into it if one exists. */ node->data = algorithms = - isc_mem_regetx(resolver->mctx, algorithms, - algorithms_len, len, ISC_MEM_ZERO); + isc_mem_creget(resolver->mctx, algorithms, + algorithms_len, len, sizeof(char)); /* store the new length */ algorithms[0] = len; } diff --git a/lib/dns/ssu.c b/lib/dns/ssu.c index 9994459e2d..e7c2ff4f3d 100644 --- a/lib/dns/ssu.c +++ b/lib/dns/ssu.c @@ -93,8 +93,8 @@ destroy(dns_ssutable_t *table) { isc_mem_put(mctx, rule->name, sizeof(*rule->name)); } if (rule->types != NULL) { - isc_mem_put(mctx, rule->types, - rule->ntypes * sizeof(*rule->types)); + isc_mem_cput(mctx, rule->types, rule->ntypes, + sizeof(*rule->types)); } ISC_LIST_UNLINK(table->rules, rule, link); rule->magic = 0; @@ -169,7 +169,7 @@ dns_ssutable_addrule(dns_ssutable_t *table, bool grant, rule->ntypes = ntypes; if (ntypes > 0) { - rule->types = isc_mem_get(mctx, ntypes * sizeof(*rule->types)); + rule->types = isc_mem_cget(mctx, ntypes, sizeof(*rule->types)); memmove(rule->types, types, ntypes * sizeof(*rule->types)); } else { rule->types = NULL; diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 6190b21808..e9c8d53490 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -1492,8 +1492,8 @@ zone_freedbargs(dns_zone_t *zone) { for (i = 0; i < zone->db_argc; i++) { isc_mem_free(zone->mctx, zone->db_argv[i]); } - isc_mem_put(zone->mctx, zone->db_argv, - zone->db_argc * sizeof(*zone->db_argv)); + isc_mem_cput(zone->mctx, zone->db_argv, zone->db_argc, + sizeof(*zone->db_argv)); } zone->db_argc = 0; zone->db_argv = NULL; @@ -1546,7 +1546,7 @@ dns_zone_setdbtype(dns_zone_t *zone, unsigned int dbargc, LOCK_ZONE(zone); /* Set up a new database argument list. */ - argv = isc_mem_get(zone->mctx, dbargc * sizeof(*argv)); + argv = isc_mem_cget(zone->mctx, dbargc, sizeof(*argv)); for (i = 0; i < dbargc; i++) { argv[i] = NULL; } @@ -18258,9 +18258,8 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *netmgr, isc_ratelimiter_create(loop, &zmgr->startupnotifyrl); isc_ratelimiter_create(loop, &zmgr->startuprefreshrl); - zmgr->mctxpool = isc_mem_getx(zmgr->mctx, - zmgr->workers * sizeof(zmgr->mctxpool[0]), - ISC_MEM_ZERO); + 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"); @@ -18473,8 +18472,8 @@ zonemgr_free(dns_zonemgr_t *zmgr) { isc_ratelimiter_detach(&zmgr->startupnotifyrl); isc_ratelimiter_detach(&zmgr->startuprefreshrl); - isc_mem_put(zmgr->mctx, zmgr->mctxpool, - zmgr->workers * sizeof(zmgr->mctxpool[0])); + isc_mem_cput(zmgr->mctx, zmgr->mctxpool, zmgr->workers, + sizeof(zmgr->mctxpool[0])); isc_rwlock_destroy(&zmgr->urlock); isc_rwlock_destroy(&zmgr->rwlock); diff --git a/lib/dns/zoneverify.c b/lib/dns/zoneverify.c index f2ff9ad38b..3a9570769b 100644 --- a/lib/dns/zoneverify.c +++ b/lib/dns/zoneverify.c @@ -1707,7 +1707,7 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { zonecut = NULL; count = dns_rdataset_count(&vctx->keyset); - dstkeys = isc_mem_get(vctx->mctx, sizeof(*dstkeys) * count); + dstkeys = isc_mem_cget(vctx->mctx, count, sizeof(*dstkeys)); for (result = dns_rdataset_first(&vctx->keyset); result == ISC_R_SUCCESS; result = dns_rdataset_next(&vctx->keyset)) @@ -1898,7 +1898,7 @@ done: while (nkeys-- > 0U) { dst_key_free(&dstkeys[nkeys]); } - isc_mem_put(vctx->mctx, dstkeys, sizeof(*dstkeys) * count); + isc_mem_cput(vctx->mctx, dstkeys, count, sizeof(*dstkeys)); if (dbiter != NULL) { dns_dbiterator_destroy(&dbiter); } diff --git a/lib/isc/commandline.c b/lib/isc/commandline.c index e8e9b5b480..c6e3568939 100644 --- a/lib/isc/commandline.c +++ b/lib/isc/commandline.c @@ -218,7 +218,7 @@ restart: if (*s == '\0') { /* We have reached the end of the string. */ *argcp = n; - *argvp = isc_mem_get(mctx, n * sizeof(char *)); + *argvp = isc_mem_cget(mctx, n, sizeof(char *)); } else { char *p = s; while (*p != ' ' && *p != '\t' && *p != '\0' && *p != '{') { diff --git a/lib/isc/heap.c b/lib/isc/heap.c index 816b80db87..2ac7c8e7f2 100644 --- a/lib/isc/heap.c +++ b/lib/isc/heap.c @@ -115,8 +115,8 @@ isc_heap_destroy(isc_heap_t **heapp) { REQUIRE(VALID_HEAP(heap)); if (heap->array != NULL) { - isc_mem_put(heap->mctx, heap->array, - heap->size * sizeof(void *)); + isc_mem_cput(heap->mctx, heap->array, heap->size, + sizeof(void *)); } heap->magic = 0; isc_mem_putanddetach(&heap->mctx, heap, sizeof(*heap)); @@ -133,8 +133,8 @@ resize(isc_heap_t *heap) { old_bytes = ISC_CHECKED_MUL(heap->size, sizeof(void *)); heap->size = new_size; - heap->array = isc_mem_reget(heap->mctx, heap->array, old_bytes, - new_bytes); + heap->array = isc_mem_creget(heap->mctx, heap->array, old_bytes, + new_bytes, sizeof(char)); } static void diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h index 18f671deb9..8a2beac8f1 100644 --- a/lib/isc/include/isc/buffer.h +++ b/lib/isc/include/isc/buffer.h @@ -1147,8 +1147,8 @@ isc_buffer_reserve(isc_buffer_t *restrict dbuf, const unsigned int size) { } dbuf->dynamic = true; } else { - dbuf->base = isc_mem_reget(dbuf->mctx, dbuf->base, dbuf->length, - len); + dbuf->base = isc_mem_creget(dbuf->mctx, dbuf->base, + dbuf->length, len, sizeof(char)); } dbuf->length = (unsigned int)len; diff --git a/lib/isc/log.c b/lib/isc/log.c index f923a16e61..b0a9f620d5 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -477,9 +477,8 @@ isc_logconfig_destroy(isc_logconfig_t **lcfgp) { } if (lcfg->channellist_count > 0) { - isc_mem_put(mctx, lcfg->channellists, - lcfg->channellist_count * - sizeof(ISC_LIST(isc_logchannellist_t))); + isc_mem_cput(mctx, lcfg->channellists, lcfg->channellist_count, + sizeof(ISC_LIST(isc_logchannellist_t))); } lcfg->dynamic = false; diff --git a/lib/isc/loop.c b/lib/isc/loop.c index 88c7fd3487..e31563b63d 100644 --- a/lib/isc/loop.c +++ b/lib/isc/loop.c @@ -339,8 +339,8 @@ isc_loopmgr_create(isc_mem_t *mctx, uint32_t nloops, isc_loopmgr_t **loopmgrp) { isc_barrier_init(&loopmgr->starting, loopmgr->nloops); isc_barrier_init(&loopmgr->stopping, loopmgr->nloops); - loopmgr->loops = isc_mem_get( - loopmgr->mctx, loopmgr->nloops * sizeof(loopmgr->loops[0])); + loopmgr->loops = isc_mem_cget(loopmgr->mctx, loopmgr->nloops, + sizeof(loopmgr->loops[0])); for (size_t i = 0; i < loopmgr->nloops; i++) { isc_loop_t *loop = &loopmgr->loops[i]; loop_init(loop, loopmgr, i); @@ -533,8 +533,8 @@ isc_loopmgr_destroy(isc_loopmgr_t **loopmgrp) { isc_loop_t *loop = &loopmgr->loops[i]; loop_close(loop); } - isc_mem_put(loopmgr->mctx, loopmgr->loops, - loopmgr->nloops * sizeof(loopmgr->loops[0])); + isc_mem_cput(loopmgr->mctx, loopmgr->loops, loopmgr->nloops, + sizeof(loopmgr->loops[0])); isc_barrier_destroy(&loopmgr->starting); isc_barrier_destroy(&loopmgr->stopping); diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index aea32f2ea3..0b5848a5be 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -2981,8 +2981,8 @@ http_init_listener_endpoints(isc_nmsocket_t *listener, INSIST(nworkers > 0); listener->h2.listener_endpoints = - isc_mem_get(listener->worker->mctx, - sizeof(isc_nm_http_endpoints_t *) * nworkers); + isc_mem_cget(listener->worker->mctx, nworkers, + sizeof(isc_nm_http_endpoints_t *)); listener->h2.n_listener_endpoints = nworkers; for (size_t i = 0; i < nworkers; i++) { listener->h2.listener_endpoints[i] = NULL; @@ -3003,9 +3003,9 @@ http_cleanup_listener_endpoints(isc_nmsocket_t *listener) { isc_nm_http_endpoints_detach( &listener->h2.listener_endpoints[i]); } - isc_mem_put(listener->worker->mctx, listener->h2.listener_endpoints, - sizeof(isc_nm_http_endpoints_t *) * - listener->h2.n_listener_endpoints); + isc_mem_cput(listener->worker->mctx, listener->h2.listener_endpoints, + listener->h2.n_listener_endpoints, + sizeof(isc_nm_http_endpoints_t *)); listener->h2.n_listener_endpoints = 0; } diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index a6968f40a7..a4c0588d91 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -216,8 +216,8 @@ isc_netmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t **netmgrp) { atomic_init(&netmgr->keepalive, 30000); atomic_init(&netmgr->advertised, 30000); - netmgr->workers = - isc_mem_get(mctx, netmgr->nloops * sizeof(netmgr->workers[0])); + netmgr->workers = isc_mem_cget(mctx, netmgr->nloops, + sizeof(netmgr->workers[0])); isc_loopmgr_teardown(loopmgr, netmgr_teardown, netmgr); @@ -269,8 +269,8 @@ nm_destroy(isc_nm_t **mgr0) { isc_mutex_destroy(&mgr->lock); - isc_mem_put(mgr->mctx, mgr->workers, - mgr->nloops * sizeof(mgr->workers[0])); + isc_mem_cput(mgr->mctx, mgr->workers, mgr->nloops, + sizeof(mgr->workers[0])); isc_mem_putanddetach(&mgr->mctx, mgr, sizeof(*mgr)); } @@ -457,8 +457,8 @@ nmsocket_cleanup(void *arg) { /* * Now free them. */ - isc_mem_put(sock->worker->mctx, sock->children, - sock->nchildren * sizeof(*sock)); + isc_mem_cput(sock->worker->mctx, sock->children, + sock->nchildren, sizeof(*sock)); sock->children = NULL; sock->nchildren = 0; } diff --git a/lib/isc/netmgr/tlsstream.c b/lib/isc/netmgr/tlsstream.c index 5de570a97b..b66afde405 100644 --- a/lib/isc/netmgr/tlsstream.c +++ b/lib/isc/netmgr/tlsstream.c @@ -1451,8 +1451,8 @@ tls_init_listener_tlsctx(isc_nmsocket_t *listener, isc_tlsctx_t *ctx) { (size_t)isc_loopmgr_nloops(listener->worker->netmgr->loopmgr); INSIST(nworkers > 0); - listener->tlsstream.listener_tls_ctx = isc_mem_get( - listener->worker->mctx, sizeof(isc_tlsctx_t *) * nworkers); + listener->tlsstream.listener_tls_ctx = isc_mem_cget( + listener->worker->mctx, nworkers, sizeof(isc_tlsctx_t *)); listener->tlsstream.n_listener_tls_ctx = nworkers; for (size_t i = 0; i < nworkers; i++) { listener->tlsstream.listener_tls_ctx[i] = NULL; @@ -1472,10 +1472,9 @@ tls_cleanup_listener_tlsctx(isc_nmsocket_t *listener) { for (size_t i = 0; i < listener->tlsstream.n_listener_tls_ctx; i++) { isc_tlsctx_free(&listener->tlsstream.listener_tls_ctx[i]); } - isc_mem_put(listener->worker->mctx, - listener->tlsstream.listener_tls_ctx, - sizeof(isc_tlsctx_t *) * - listener->tlsstream.n_listener_tls_ctx); + isc_mem_cput( + listener->worker->mctx, listener->tlsstream.listener_tls_ctx, + listener->tlsstream.n_listener_tls_ctx, sizeof(isc_tlsctx_t *)); listener->tlsstream.n_listener_tls_ctx = 0; } diff --git a/lib/isc/stats.c b/lib/isc/stats.c index a4b8ce1855..5cc6e3d2b1 100644 --- a/lib/isc/stats.c +++ b/lib/isc/stats.c @@ -57,9 +57,8 @@ isc_stats_detach(isc_stats_t **statsp) { if (isc_refcount_decrement(&stats->references) == 1) { isc_refcount_destroy(&stats->references); - isc_mem_put(stats->mctx, stats->counters, - sizeof(isc__atomic_statcounter_t) * - stats->ncounters); + isc_mem_cput(stats->mctx, stats->counters, stats->ncounters, + sizeof(isc__atomic_statcounter_t)); isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats)); } } @@ -183,8 +182,8 @@ isc_stats_resize(isc_stats_t **statsp, int ncounters) { uint32_t counter = atomic_load_acquire(&stats->counters[i]); atomic_store_release(&newcounters[i], counter); } - isc_mem_put(stats->mctx, stats->counters, - sizeof(isc__atomic_statcounter_t) * stats->ncounters); + isc_mem_cput(stats->mctx, stats->counters, stats->ncounters, + sizeof(isc__atomic_statcounter_t)); stats->counters = newcounters; stats->ncounters = ncounters; } diff --git a/lib/isc/symtab.c b/lib/isc/symtab.c index f8028a2ca5..d96ab3dc60 100644 --- a/lib/isc/symtab.c +++ b/lib/isc/symtab.c @@ -62,7 +62,7 @@ isc_symtab_create(isc_mem_t *mctx, unsigned int size, symtab->mctx = NULL; isc_mem_attach(mctx, &symtab->mctx); - symtab->table = isc_mem_get(mctx, size * sizeof(eltlist_t)); + symtab->table = isc_mem_cget(mctx, size, sizeof(eltlist_t)); for (i = 0; i < size; i++) { INIT_LIST(symtab->table[i]); } @@ -101,8 +101,8 @@ isc_symtab_destroy(isc_symtab_t **symtabp) { isc_mem_put(symtab->mctx, elt, sizeof(*elt)); } } - isc_mem_put(symtab->mctx, symtab->table, - symtab->size * sizeof(eltlist_t)); + isc_mem_cput(symtab->mctx, symtab->table, symtab->size, + sizeof(eltlist_t)); symtab->magic = 0; isc_mem_putanddetach(&symtab->mctx, symtab, sizeof(*symtab)); } @@ -177,7 +177,7 @@ grow_table(isc_symtab_t *symtab) { newmax = newsize * 3 / 4; INSIST(newsize > 0U && newmax > 0U); - newtable = isc_mem_get(symtab->mctx, newsize * sizeof(eltlist_t)); + newtable = isc_mem_cget(symtab->mctx, newsize, sizeof(eltlist_t)); for (i = 0; i < newsize; i++) { INIT_LIST(newtable[i]); @@ -197,8 +197,8 @@ grow_table(isc_symtab_t *symtab) { } } - isc_mem_put(symtab->mctx, symtab->table, - symtab->size * sizeof(eltlist_t)); + isc_mem_cput(symtab->mctx, symtab->table, symtab->size, + sizeof(eltlist_t)); symtab->table = newtable; symtab->size = newsize; diff --git a/lib/isc/tls.c b/lib/isc/tls.c index d57cf98d1e..2f15f3fd2c 100644 --- a/lib/isc/tls.c +++ b/lib/isc/tls.c @@ -195,8 +195,8 @@ isc__tls_initialize(void) { RUNTIME_CHECK(OPENSSL_init_ssl(opts, NULL) == 1); #else nlocks = CRYPTO_num_locks(); - locks = isc_mem_getx(isc__tls_mctx, nlocks * sizeof(locks[0]), - ISC_MEM_ZERO); + locks = isc_mem_cgetx(isc__tls_mctx, nlocks, sizeof(locks[0]), + ISC_MEM_ZERO); isc_mutexblock_init(locks, nlocks); CRYPTO_set_locking_callback(isc__tls_lock_callback); CRYPTO_THREADID_set_callback(isc__tls_set_thread_id); @@ -245,7 +245,7 @@ isc__tls_shutdown(void) { if (locks != NULL) { isc_mutexblock_destroy(locks, nlocks); - isc_mem_put(isc__tls_mctx, locks, nlocks * sizeof(locks[0])); + isc_mem_cput(isc__tls_mctx, locks, nlocks, sizeof(locks[0])); locks = NULL; } #endif diff --git a/lib/isccfg/check.c b/lib/isccfg/check.c index c55d9fa241..a1740814dc 100644 --- a/lib/isccfg/check.c +++ b/lib/isccfg/check.c @@ -2447,7 +2447,7 @@ resume: goto resume; } if (stack != NULL) { - isc_mem_put(mctx, stack, stackcount * sizeof(*stack)); + isc_mem_cput(mctx, stack, stackcount, sizeof(*stack)); } isc_symtab_destroy(&symtab); *countp = count; diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index ec2d56149a..0dac6e381c 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -301,8 +301,8 @@ cfg_create_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { } CHECK(cfg_create_obj(pctx, type, &obj)); - obj->value.tuple = isc_mem_get(pctx->mctx, - nfields * sizeof(cfg_obj_t *)); + obj->value.tuple = isc_mem_cget(pctx->mctx, nfields, + sizeof(cfg_obj_t *)); for (f = fields, i = 0; f->name != NULL; f++, i++) { obj->value.tuple[i] = NULL; } @@ -401,8 +401,8 @@ free_tuple(cfg_parser_t *pctx, cfg_obj_t *obj) { CLEANUP_OBJ(obj->value.tuple[i]); nfields++; } - isc_mem_put(pctx->mctx, obj->value.tuple, - nfields * sizeof(cfg_obj_t *)); + isc_mem_cput(pctx->mctx, obj->value.tuple, nfields, + sizeof(cfg_obj_t *)); } bool diff --git a/lib/ns/client.c b/lib/ns/client.c index 2c87a845fc..f13ff04c76 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -371,9 +371,9 @@ client_sendpkg(ns_client_t *client, isc_buffer_t *buffer) { if (isc_buffer_base(buffer) == client->tcpbuf) { size_t used = isc_buffer_usedlength(buffer); - client->tcpbuf = isc_mem_reget(client->manager->mctx, - client->tcpbuf, - client->tcpbuf_size, used); + client->tcpbuf = + isc_mem_creget(client->manager->mctx, client->tcpbuf, + client->tcpbuf_size, used, sizeof(char)); client->tcpbuf_size = used; r.base = client->tcpbuf; r.length = used; diff --git a/lib/ns/interfacemgr.c b/lib/ns/interfacemgr.c index ae73e42340..08e70f022c 100644 --- a/lib/ns/interfacemgr.c +++ b/lib/ns/interfacemgr.c @@ -322,8 +322,8 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, mgr->magic = IFMGR_MAGIC; *mgrp = mgr; - mgr->clientmgrs = isc_mem_get(mgr->mctx, - mgr->ncpus * sizeof(mgr->clientmgrs[0])); + mgr->clientmgrs = isc_mem_cget(mgr->mctx, mgr->ncpus, + sizeof(mgr->clientmgrs[0])); for (size_t i = 0; i < mgr->ncpus; i++) { result = ns_clientmgr_create(mgr->sctx, mgr->loopmgr, mgr->aclenv, (int)i, @@ -371,8 +371,8 @@ ns_interfacemgr_destroy(ns_interfacemgr_t *mgr) { for (size_t i = 0; i < mgr->ncpus; i++) { ns_clientmgr_detach(&mgr->clientmgrs[i]); } - isc_mem_put(mgr->mctx, mgr->clientmgrs, - mgr->ncpus * sizeof(mgr->clientmgrs[0])); + isc_mem_cput(mgr->mctx, mgr->clientmgrs, mgr->ncpus, + sizeof(mgr->clientmgrs[0])); if (mgr->sctx != NULL) { ns_server_detach(&mgr->sctx); diff --git a/lib/ns/query.c b/lib/ns/query.c index 0b3d359d17..f5e89bd50a 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -731,8 +731,8 @@ query_reset(ns_client_t *client, bool everything) { ns_client_putrdataset(client, &client->query.dns64_sigaaaa); } if (client->query.dns64_aaaaok != NULL) { - isc_mem_put(client->manager->mctx, client->query.dns64_aaaaok, - client->query.dns64_aaaaoklen * sizeof(bool)); + isc_mem_cput(client->manager->mctx, client->query.dns64_aaaaok, + client->query.dns64_aaaaoklen, sizeof(bool)); client->query.dns64_aaaaok = NULL; client->query.dns64_aaaaoklen = 0; } @@ -4962,7 +4962,7 @@ dns64_aaaaok(ns_client_t *client, dns_rdataset_t *rdataset, } count = dns_rdataset_count(rdataset); - aaaaok = isc_mem_get(client->manager->mctx, sizeof(bool) * count); + aaaaok = isc_mem_cget(client->manager->mctx, count, sizeof(bool)); isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr); if (dns_dns64_aaaaok(dns64, &netaddr, client->signer, env, flags, @@ -4976,14 +4976,14 @@ dns64_aaaaok(ns_client_t *client, dns_rdataset_t *rdataset, } } if (aaaaok != NULL) { - isc_mem_put(client->manager->mctx, aaaaok, - sizeof(bool) * count); + isc_mem_cput(client->manager->mctx, aaaaok, count, + sizeof(bool)); } return (true); } if (aaaaok != NULL) { - isc_mem_put(client->manager->mctx, aaaaok, - sizeof(bool) * count); + isc_mem_cput(client->manager->mctx, aaaaok, count, + sizeof(bool)); } return (false); } diff --git a/lib/ns/update.c b/lib/ns/update.c index 7be4f641fb..9f9716451b 100644 --- a/lib/ns/update.c +++ b/lib/ns/update.c @@ -1700,8 +1700,7 @@ send_update(ns_client_t *client, dns_zone_t *zone) { */ if (ssutable != NULL) { ruleslen = request->counts[DNS_SECTION_UPDATE]; - rules = isc_mem_getx(mctx, sizeof(*rules) * ruleslen, - ISC_MEM_ZERO); + rules = isc_mem_cget(mctx, ruleslen, sizeof(*rules)); } for (rule = 0, @@ -1912,7 +1911,7 @@ failure: } if (rules != NULL) { - isc_mem_put(mctx, rules, sizeof(*rules) * ruleslen); + isc_mem_cput(mctx, rules, ruleslen, sizeof(*rules)); } if (ssutable != NULL) { @@ -3461,7 +3460,7 @@ common: } if (rules != NULL) { - isc_mem_put(mctx, rules, sizeof(*rules) * ruleslen); + isc_mem_cput(mctx, rules, ruleslen, sizeof(*rules)); } if (ssutable != NULL) { diff --git a/tests/isc/doh_test.c b/tests/isc/doh_test.c index 112b827257..91d2ed8e2d 100644 --- a/tests/isc/doh_test.c +++ b/tests/isc/doh_test.c @@ -314,7 +314,7 @@ setup_test(void **state) { setup_loopmgr(state); - nm = isc_mem_get(mctx, MAX_NM * sizeof(nm[0])); + nm = isc_mem_cget(mctx, MAX_NM, sizeof(nm[0])); for (size_t i = 0; i < MAX_NM; i++) { isc_netmgr_create(mctx, loopmgr, &nm[i]); assert_non_null(nm[i]); @@ -348,7 +348,7 @@ teardown_test(void **state ISC_ATTR_UNUSED) { isc_netmgr_destroy(&nm[i]); assert_null(nm[i]); } - isc_mem_put(mctx, nm, MAX_NM * sizeof(nm[0])); + isc_mem_cput(mctx, nm, MAX_NM, sizeof(nm[0])); teardown_loopmgr(state); diff --git a/tests/isc/hashmap_test.c b/tests/isc/hashmap_test.c index ed15f6fc24..6f2f3d3d7c 100644 --- a/tests/isc/hashmap_test.c +++ b/tests/isc/hashmap_test.c @@ -48,9 +48,9 @@ test_hashmap_full(uint8_t init_bits, uintptr_t count) { isc_result_t result; test_node_t *nodes, *long_nodes, *upper_nodes; - nodes = isc_mem_get(mctx, count * sizeof(nodes[0])); - long_nodes = isc_mem_get(mctx, count * sizeof(nodes[0])); - upper_nodes = isc_mem_get(mctx, count * sizeof(nodes[0])); + nodes = isc_mem_cget(mctx, count, sizeof(nodes[0])); + long_nodes = isc_mem_cget(mctx, count, sizeof(nodes[0])); + upper_nodes = isc_mem_cget(mctx, count, sizeof(nodes[0])); isc_hashmap_create(mctx, init_bits, ISC_HASHMAP_CASE_SENSITIVE, &hashmap); @@ -172,9 +172,9 @@ test_hashmap_full(uint8_t init_bits, uintptr_t count) { isc_hashmap_destroy(&hashmap); assert_null(hashmap); - isc_mem_put(mctx, nodes, count * sizeof(nodes[0])); - isc_mem_put(mctx, long_nodes, count * sizeof(nodes[0])); - isc_mem_put(mctx, upper_nodes, count * sizeof(nodes[0])); + isc_mem_cput(mctx, nodes, count, sizeof(nodes[0])); + isc_mem_cput(mctx, long_nodes, count, sizeof(nodes[0])); + isc_mem_cput(mctx, upper_nodes, count, sizeof(nodes[0])); } static void @@ -187,7 +187,7 @@ test_hashmap_iterator(void) { size_t tksize; test_node_t *nodes; - nodes = isc_mem_get(mctx, count * sizeof(nodes[0])); + nodes = isc_mem_cget(mctx, count, sizeof(nodes[0])); isc_hashmap_create(mctx, HASHMAP_MIN_BITS, ISC_HASHMAP_CASE_SENSITIVE, &hashmap); @@ -310,7 +310,7 @@ test_hashmap_iterator(void) { isc_hashmap_destroy(&hashmap); assert_null(hashmap); - isc_mem_put(mctx, nodes, count * sizeof(nodes[0])); + isc_mem_cput(mctx, nodes, count, sizeof(nodes[0])); } /* 1 bit, 120 elements test, full rehashing */ diff --git a/tests/isc/mutex_test.c b/tests/isc/mutex_test.c index 3348964989..35e2d598d6 100644 --- a/tests/isc/mutex_test.c +++ b/tests/isc/mutex_test.c @@ -115,7 +115,7 @@ isc_mutex_thread(void *arg) { } ISC_RUN_TEST_IMPL(isc_mutex_benchmark) { - isc_thread_t *threads = isc_mem_get(mctx, sizeof(*threads) * workers); + isc_thread_t *threads = isc_mem_cget(mctx, workers, sizeof(*threads)); isc_time_t ts1, ts2; double t; int dc; @@ -201,7 +201,7 @@ ISC_RUN_TEST_IMPL(isc_mutex_benchmark) { isc_mutex_destroy(&lock); - isc_mem_put(mctx, threads, sizeof(*threads) * workers); + isc_mem_cput(mctx, threads, workers, sizeof(*threads)); } ISC_TEST_LIST_START diff --git a/tests/isc/random_test.c b/tests/isc/random_test.c index 391a0e0800..05e3bea0ea 100644 --- a/tests/isc/random_test.c +++ b/tests/isc/random_test.c @@ -520,7 +520,7 @@ blockfrequency(uint16_t *values, size_t length) { assert_true(numblocks < 100); assert_true(numbits >= (mbits * numblocks)); - pi = isc_mem_get(mctx, numblocks * sizeof(double)); + pi = isc_mem_cget(mctx, numblocks, sizeof(double)); assert_non_null(pi); for (i = 0; i < numblocks; i++) { @@ -543,7 +543,7 @@ blockfrequency(uint16_t *values, size_t length) { chi_square *= 4 * mbits; - isc_mem_put(mctx, pi, numblocks * sizeof(double)); + isc_mem_cput(mctx, pi, numblocks, sizeof(double)); p_value = igamc(numblocks * 0.5, chi_square * 0.5); diff --git a/tests/isc/rwlock_test.c b/tests/isc/rwlock_test.c index 90452159c6..4c5b8e0575 100644 --- a/tests/isc/rwlock_test.c +++ b/tests/isc/rwlock_test.c @@ -71,7 +71,7 @@ setup_env(void **unused __attribute__((__unused__))) { } assert_int_not_equal(delay_loop, 0); - rnd = isc_mem_get(mctx, loops * sizeof(rnd[0])); + rnd = isc_mem_cget(mctx, loops, sizeof(rnd[0])); for (size_t i = 0; i < loops; i++) { rnd[i] = (uint8_t)isc_random_uniform(100); } @@ -81,7 +81,7 @@ setup_env(void **unused __attribute__((__unused__))) { static int teardown_env(void **state __attribute__((__unused__))) { - isc_mem_put(mctx, rnd, loops * sizeof(rnd[0])); + isc_mem_cput(mctx, rnd, loops, sizeof(rnd[0])); return (0); } @@ -316,7 +316,7 @@ isc__rwlock_benchmark(isc_thread_t *threads, unsigned int nthreads, } ISC_RUN_TEST_IMPL(isc_rwlock_benchmark) { - isc_thread_t *threads = isc_mem_get(mctx, sizeof(*threads) * workers); + isc_thread_t *threads = isc_mem_cget(mctx, workers, sizeof(*threads)); memset(threads, 0, sizeof(*threads) * workers); @@ -330,7 +330,7 @@ ISC_RUN_TEST_IMPL(isc_rwlock_benchmark) { isc__rwlock_benchmark(threads, nthreads, 100); } - isc_mem_put(mctx, threads, sizeof(*threads) * workers); + isc_mem_cput(mctx, threads, workers, sizeof(*threads)); } ISC_TEST_LIST_START diff --git a/tests/isc/spinlock_test.c b/tests/isc/spinlock_test.c index 148832babf..ce500213d9 100644 --- a/tests/isc/spinlock_test.c +++ b/tests/isc/spinlock_test.c @@ -124,7 +124,7 @@ isc_spinlock_thread(void *arg) { } ISC_RUN_TEST_IMPL(isc_spinlock_benchmark) { - isc_thread_t *threads = isc_mem_get(mctx, sizeof(*threads) * workers); + isc_thread_t *threads = isc_mem_cget(mctx, workers, sizeof(*threads)); isc_time_t ts1, ts2; double t; int dc; @@ -211,7 +211,7 @@ ISC_RUN_TEST_IMPL(isc_spinlock_benchmark) { isc_spinlock_destroy(&lock); - isc_mem_put(mctx, threads, sizeof(*threads) * workers); + isc_mem_cput(mctx, threads, workers, sizeof(*threads)); } ISC_TEST_LIST_START