return (ISC_R_SUCCESS);
}
-#define grow_array(mctx, array, newlen, oldlen) \
- if (newlen >= oldlen) { \
- size_t newsize = (newlen + 16) * sizeof(array[0]); \
- size_t oldsize = oldlen * sizeof(array[0]); \
- array = isc_mem_regetx(mctx, array, oldsize, newsize, \
- ISC_MEM_ZERO); \
- oldlen = newlen + 16; \
- }
-
-#define shrink_array(mctx, array, newlen, oldlen) \
- if (newlen < oldlen) { \
- size_t newsize = newlen * sizeof(array[0]); \
- size_t oldsize = oldlen * sizeof(array[0]); \
- array = isc_mem_regetx(mctx, array, oldsize, newsize, \
- ISC_MEM_ZERO); \
- oldlen = newlen; \
+#define grow_array(mctx, array, newlen, oldlen) \
+ if (newlen >= oldlen) { \
+ array = isc_mem_creget(mctx, array, oldlen, newlen + 16, \
+ sizeof(array[0])); \
+ oldlen = newlen + 16; \
+ }
+
+#define shrink_array(mctx, array, newlen, oldlen) \
+ if (newlen < oldlen) { \
+ array = isc_mem_creget(mctx, array, oldlen, newlen, \
+ sizeof(array[0])); \
+ oldlen = newlen; \
}
isc_result_t
if (default_servers) {
char serverstr[DNS_NAME_MAXTEXT + 1];
isc_buffer_t buf;
- size_t size;
isc_buffer_init(&buf, serverstr, sizeof(serverstr));
result = dns_name_totext(&primary, DNS_NAME_OMITFINALDOT, &buf);
sizeof(isc_sockaddr_t));
}
primary_alloc = MAX_SERVERADDRS;
- size = primary_alloc * sizeof(isc_sockaddr_t);
- primary_servers = isc_mem_getx(gmctx, size, ISC_MEM_ZERO);
+ primary_servers = isc_mem_cget(gmctx, primary_alloc,
+ sizeof(isc_sockaddr_t));
primary_total = get_addresses(serverstr, dnsport,
primary_servers, primary_alloc);
if (primary_total == 0) {
if ((flags & DNS_COMPRESS_LARGE) != 0) {
size_t count = (1 << DNS_COMPRESS_LARGEBITS);
- size_t size = count * sizeof(*set);
mask = count - 1;
- set = isc_mem_allocatex(mctx, size, ISC_MEM_ZERO);
+ set = isc_mem_callocate(mctx, count, sizeof(*set));
} else {
mask = ARRAY_SIZE(cctx->smallset) - 1;
set = cctx->smallset;
isc_result_t
dns_ipkeylist_resize(isc_mem_t *mctx, dns_ipkeylist_t *ipkl, unsigned int n) {
- isc_sockaddr_t *addrs = NULL;
- isc_sockaddr_t *sources = NULL;
- dns_name_t **keys = NULL;
- dns_name_t **tlss = NULL;
- dns_name_t **labels = NULL;
-
REQUIRE(ipkl != NULL);
REQUIRE(n > ipkl->count);
return (ISC_R_SUCCESS);
}
- 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_cput(mctx, ipkl->addrs, ipkl->allocated,
- sizeof(isc_sockaddr_t));
- }
- ipkl->addrs = addrs;
- memset(&ipkl->addrs[ipkl->allocated], 0,
- (n - ipkl->allocated) * sizeof(isc_sockaddr_t));
-
- if (ipkl->sources != NULL) {
- memmove(sources, 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,
- (n - ipkl->allocated) * sizeof(isc_sockaddr_t));
-
- if (ipkl->keys) {
- memmove(keys, 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,
- (n - ipkl->allocated) * sizeof(dns_name_t *));
-
- if (ipkl->tlss) {
- memmove(tlss, 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,
- (n - ipkl->allocated) * sizeof(dns_name_t *));
-
- if (ipkl->labels != NULL) {
- memmove(labels, 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,
- (n - ipkl->allocated) * sizeof(dns_name_t *));
+ ipkl->addrs = isc_mem_creget(mctx, ipkl->addrs, ipkl->allocated, n,
+ sizeof(isc_sockaddr_t));
+ ipkl->sources = isc_mem_creget(mctx, ipkl->addrs, ipkl->allocated, n,
+ sizeof(isc_sockaddr_t));
+ ipkl->keys = isc_mem_creget(mctx, ipkl->addrs, ipkl->allocated, n,
+ sizeof(dns_name_t *));
+ ipkl->tlss = isc_mem_creget(mctx, ipkl->addrs, ipkl->allocated, n,
+ sizeof(dns_name_t *));
+ ipkl->labels = isc_mem_creget(mctx, ipkl->addrs, ipkl->allocated, n,
+ sizeof(dns_name_t *));
ipkl->allocated = n;
return (ISC_R_SUCCESS);
-
- 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);
}
#include <isc/dir.h>
#include <isc/file.h>
#include <isc/mem.h>
+#include <isc/overflow.h>
#include <isc/result.h>
#include <isc/serial.h>
#include <isc/stdio.h>
journal_header_encode(&header, &rawheader);
size = sizeof(journal_rawheader_t) +
- index_size * sizeof(journal_rawpos_t);
+ ISC_CHECKED_MUL(index_size, sizeof(journal_rawpos_t));
mem = isc_mem_getx(mctx, size, ISC_MEM_ZERO);
memmove(mem, &rawheader, sizeof(rawheader));
unsigned int rawbytes;
unsigned char *p;
- rawbytes = j->header.index_size * sizeof(journal_rawpos_t);
+ rawbytes = ISC_CHECKED_MUL(j->header.index_size,
+ sizeof(journal_rawpos_t));
j->rawindex = isc_mem_get(mctx, rawbytes);
CHECK(journal_read(j, j->rawindex, rawbytes));
*/
if (JOURNAL_EMPTY(&j->header)) {
offset = sizeof(journal_rawheader_t) +
- j->header.index_size * sizeof(journal_rawpos_t);
+ ISC_CHECKED_MUL(j->header.index_size,
+ sizeof(journal_rawpos_t));
} else {
offset = j->header.end.offset;
}
* (We don't need to worry about the transaction header
* because that was already excluded from xdr.size.)
*/
- *xfrsizep = size - (count * sizeof(journal_rawrrhdr_t));
+ *xfrsizep = size - (ISC_CHECKED_MUL(
+ count, sizeof(journal_rawrrhdr_t)));
}
result = ISC_R_SUCCESS;
* Cope with very small target sizes.
*/
indexend = sizeof(journal_rawheader_t) +
- j1->header.index_size * sizeof(journal_rawpos_t);
+ ISC_CHECKED_MUL(j1->header.index_size,
+ sizeof(journal_rawpos_t));
if (target_size < DNS_JOURNAL_SIZE_MIN) {
target_size = DNS_JOURNAL_SIZE_MIN;
}
unsigned char *p;
unsigned int rawbytes;
- rawbytes = j->header.index_size * sizeof(journal_rawpos_t);
+ rawbytes = ISC_CHECKED_MUL(j->header.index_size,
+ sizeof(journal_rawpos_t));
p = j->rawindex;
for (i = 0; i < j->header.index_size; i++) {
ISC_LIST(dns_rdatalist_t) save;
dns_rdatalist_t *this;
- newlist = isc_mem_get(mctx, new_len * sizeof(*newlist));
- if (newlist == NULL) {
- return (NULL);
- }
+ newlist = isc_mem_cget(mctx, new_len, sizeof(newlist[0]));
ISC_LIST_INIT(save);
while ((this = ISC_LIST_HEAD(*current)) != NULL) {
INSIST(rdlcount == old_len);
if (oldlist != NULL) {
- isc_mem_put(mctx, oldlist, old_len * sizeof(*oldlist));
+ isc_mem_cput(mctx, oldlist, old_len, sizeof(*oldlist));
}
return (newlist);
}
dns_rdatalist_t *this;
dns_rdata_t *rdata;
- newlist = isc_mem_get(mctx, new_len * sizeof(*newlist));
- if (newlist == NULL) {
- return (NULL);
- }
- memset(newlist, 0, new_len * sizeof(*newlist));
+ newlist = isc_mem_cget(mctx, new_len, sizeof(*newlist));
/*
* Copy current relinking.
}
INSIST(rdcount == old_len || rdcount == 0);
if (oldlist != NULL) {
- isc_mem_put(mctx, oldlist, old_len * sizeof(*oldlist));
+ isc_mem_cput(mctx, oldlist, old_len, sizeof(*oldlist));
}
return (newlist);
}
*/
static void
hashtable_new(dns_rbt_t *rbt, uint8_t index, uint8_t bits) {
- size_t size;
-
REQUIRE(rbt->hashbits[index] == 0U);
REQUIRE(rbt->hashtable[index] == NULL);
REQUIRE(bits >= ISC_HASH_MIN_BITS);
rbt->hashbits[index] = bits;
- size = ISC_HASHSIZE(rbt->hashbits[index]) * sizeof(dns_rbtnode_t *);
- rbt->hashtable[index] = isc_mem_getx(rbt->mctx, size, ISC_MEM_ZERO);
+ rbt->hashtable[index] = isc_mem_cget(rbt->mctx,
+ ISC_HASHSIZE(rbt->hashbits[index]),
+ sizeof(dns_rbtnode_t *));
}
static void
hashtable_free(dns_rbt_t *rbt, uint8_t index) {
- size_t size = ISC_HASHSIZE(rbt->hashbits[index]) *
- sizeof(dns_rbtnode_t *);
- isc_mem_put(rbt->mctx, rbt->hashtable[index], size);
+ isc_mem_cput(rbt->mctx, rbt->hashtable[index],
+ ISC_HASHSIZE(rbt->hashbits[index]),
+ sizeof(dns_rbtnode_t *));
rbt->hashbits[index] = 0U;
rbt->hashtable[index] = NULL;
isc_mem_attach(mctx, &requestmgr->mctx);
uint32_t nloops = isc_loopmgr_nloops(requestmgr->loopmgr);
- requestmgr->requests = isc_mem_getx(
- requestmgr->mctx, nloops * sizeof(requestmgr->requests[0]),
- ISC_MEM_ZERO);
+ requestmgr->requests = isc_mem_cget(requestmgr->mctx, nloops,
+ sizeof(requestmgr->requests[0]));
for (size_t i = 0; i < nloops; i++) {
ISC_LIST_INIT(requestmgr->requests[i]);
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/netaddr.h>
+#include <isc/overflow.h>
#include <isc/result.h>
#include <isc/util.h>
}
bsize = sizeof(dns_rrl_block_t) +
- (newsize - 1) * sizeof(dns_rrl_entry_t);
+ ISC_CHECKED_MUL((newsize - 1), sizeof(dns_rrl_entry_t));
b = isc_mem_getx(rrl->mctx, bsize, ISC_MEM_ZERO);
b->size = bsize;
isc_mem_put(rrl->mctx, old_hash,
sizeof(*old_hash) +
- (old_hash->length - 1) * sizeof(old_hash->bins[0]));
+ ISC_CHECKED_MUL((old_hash->length - 1),
+ sizeof(old_hash->bins[0])));
rrl->old_hash = NULL;
}
}
new_bins = hash_divisor(new_bins);
- hsize = sizeof(dns_rrl_hash_t) + (new_bins - 1) * sizeof(hash->bins[0]);
+ hsize = sizeof(dns_rrl_hash_t) +
+ ISC_CHECKED_MUL((new_bins - 1), sizeof(hash->bins[0]));
hash = isc_mem_getx(rrl->mctx, hsize, ISC_MEM_ZERO);
hash->length = new_bins;
rrl->hash_gen ^= 1;
h = rrl->hash;
if (h != NULL) {
isc_mem_put(rrl->mctx, h,
- sizeof(*h) + (h->length - 1) * sizeof(h->bins[0]));
+ sizeof(*h) + ISC_CHECKED_MUL((h->length - 1),
+ sizeof(h->bins[0])));
}
h = rrl->old_hash;
if (h != NULL) {
isc_mem_put(rrl->mctx, h,
- sizeof(*h) + (h->length - 1) * sizeof(h->bins[0]));
+ sizeof(*h) + ISC_CHECKED_MUL((h->length - 1),
+ sizeof(h->bins[0])));
}
isc_mem_putanddetach(&rrl->mctx, rrl, sizeof(*rrl));
REQUIRE(tablep != NULL && *tablep == NULL);
REQUIRE(mctx != NULL);
- table = isc_mem_get(mctx, sizeof(dns_ssutable_t));
+ table = isc_mem_get(mctx, sizeof(*table));
isc_refcount_init(&table->references, 1);
table->mctx = NULL;
isc_mem_attach(mctx, &table->mctx);
#include <isc/loop.h>
#include <isc/md.h>
#include <isc/mutex.h>
+#include <isc/overflow.h>
#include <isc/random.h>
#include <isc/ratelimiter.h>
#include <isc/refcount.h>
REQUIRE(argv != NULL && *argv == NULL);
LOCK_ZONE(zone);
- size = (zone->db_argc + 1) * sizeof(char *);
+ size = ISC_CHECKED_MUL((zone->db_argc + 1), sizeof(char *));
for (i = 0; i < zone->db_argc; i++) {
size += strlen(zone->db_argv[i]) + 1;
}
tmp = mem;
tmp2 = mem;
base = mem;
- tmp2 += (zone->db_argc + 1) * sizeof(char *);
+ tmp2 += ISC_CHECKED_MUL((zone->db_argc + 1), sizeof(char *));
for (i = 0; i < zone->db_argc; i++) {
*tmp++ = tmp2;
strlcpy(tmp2, zone->db_argv[i], size - (tmp2 - base));
static void
hashmap_create_table(isc_hashmap_t *hashmap, const uint8_t idx,
const uint8_t bits) {
- size_t size;
-
REQUIRE(hashmap->tables[idx].hashbits == HASHMAP_NO_BITS);
REQUIRE(hashmap->tables[idx].table == NULL);
REQUIRE(bits >= HASHMAP_MIN_BITS);
.size = HASHSIZE(bits),
};
- size = hashmap->tables[idx].size *
- sizeof(hashmap->tables[idx].table[0]);
-
- hashmap->tables[idx].table = isc_mem_getx(hashmap->mctx, size,
- ISC_MEM_ZERO);
+ hashmap->tables[idx].table =
+ isc_mem_cget(hashmap->mctx, hashmap->tables[idx].size,
+ sizeof(hashmap->tables[idx].table[0]));
}
static void
#define EXPONENTS(hg) (CHUNKS - DENORMALS(hg))
#define BUCKETS(hg) (EXPONENTS(hg) * MANTISSAS(hg))
-#define MAXCHUNK(hg) EXPONENTS(hg)
-#define CHUNKSIZE(hg) MANTISSAS(hg)
-#define CHUNKBYTES(hg) (CHUNKSIZE(hg) * sizeof(hg_bucket_t))
+#define MAXCHUNK(hg) EXPONENTS(hg)
+#define CHUNKSIZE(hg) MANTISSAS(hg)
typedef atomic_uint_fast64_t hg_bucket_t;
typedef atomic_ptr(hg_bucket_t) hg_chunk_t;
for (uint c = 0; c < CHUNKS; c++) {
if (hg->chunk[c] != NULL) {
- isc_mem_put(hg->mctx, hg->chunk[c], CHUNKBYTES(hg));
+ isc_mem_cput(hg->mctx, hg->chunk[c], CHUNKSIZE(hg),
+ sizeof(hg_bucket_t));
}
}
isc_mem_putanddetach(&hg->mctx, hg, sizeof(*hg));
uint chunksize = CHUNKSIZE(hg);
uint chunk = key / chunksize;
uint bucket = key % chunksize;
- size_t bytes = CHUNKBYTES(hg);
hg_bucket_t *old_cp = NULL;
- hg_bucket_t *new_cp = isc_mem_getx(hg->mctx, bytes, ISC_MEM_ZERO);
+ hg_bucket_t *new_cp = isc_mem_cget(hg->mctx, CHUNKSIZE(hg),
+ sizeof(hg_bucket_t));
hg_chunk_t *cpp = &hg->chunk[chunk];
if (atomic_compare_exchange_strong_acq_rel(cpp, &old_cp, new_cp)) {
return (&new_cp[bucket]);
} else {
/* lost the race, so use the winner's chunk */
- isc_mem_put(hg->mctx, new_cp, bytes);
+ isc_mem_cput(hg->mctx, new_cp, CHUNKSIZE(hg),
+ sizeof(hg_bucket_t));
return (&old_cp[bucket]);
}
}
static void
hashtable_new(isc_ht_t *ht, const uint8_t idx, const uint8_t bits) {
- size_t size;
REQUIRE(ht->hashbits[idx] == HT_NO_BITS);
REQUIRE(ht->table[idx] == NULL);
REQUIRE(bits >= HT_MIN_BITS);
ht->hashbits[idx] = bits;
ht->size[idx] = HASHSIZE(ht->hashbits[idx]);
- size = ht->size[idx] * sizeof(isc_ht_node_t *);
-
- ht->table[idx] = isc_mem_getx(ht->mctx, size, ISC_MEM_ZERO);
+ ht->table[idx] = isc_mem_cget(ht->mctx, ht->size[idx],
+ sizeof(isc_ht_node_t *));
}
static void
hashtable_free(isc_ht_t *ht, const uint8_t idx) {
- size_t size = ht->size[idx] * sizeof(isc_ht_node_t *);
-
for (size_t i = 0; i < ht->size[idx]; i++) {
isc_ht_node_t *node = ht->table[idx][i];
while (node != NULL) {
}
}
- isc_mem_put(ht->mctx, ht->table[idx], size);
+ isc_mem_cput(ht->mctx, ht->table[idx], ht->size[idx],
+ sizeof(isc_ht_node_t *));
+
ht->hashbits[idx] = HT_NO_BITS;
ht->table[idx] = NULL;
}
*/
static void
sync_channellist(isc_logconfig_t *lcfg) {
- unsigned int bytes;
- isc_log_t *lctx;
- void *lists;
-
REQUIRE(VALID_CONFIG(lcfg));
- lctx = lcfg->lctx;
+ isc_log_t *lctx = lcfg->lctx;
REQUIRE(lctx->category_count != 0);
return;
}
- bytes = lctx->category_count * sizeof(ISC_LIST(isc_logchannellist_t));
-
- lists = isc_mem_getx(lctx->mctx, bytes, ISC_MEM_ZERO);
-
- if (lcfg->channellist_count != 0) {
- bytes = lcfg->channellist_count *
- sizeof(ISC_LIST(isc_logchannellist_t));
- memmove(lists, lcfg->channellists, bytes);
- isc_mem_put(lctx->mctx, lcfg->channellists, bytes);
- }
+ lcfg->channellists = isc_mem_creget(
+ lctx->mctx, lcfg->channellists, lcfg->channellist_count,
+ lctx->category_count, sizeof(ISC_LIST(isc_logchannellist_t)));
- lcfg->channellists = lists;
lcfg->channellist_count = lctx->category_count;
}
if ((ctx->debugging & ISC_MEM_DEBUGRECORD) != 0) {
unsigned int i;
- ctx->debuglist =
- mallocx((DEBUG_TABLE_COUNT * sizeof(debuglist_t)), 0);
+ ctx->debuglist = calloc(DEBUG_TABLE_COUNT, sizeof(debuglist_t));
INSIST(ctx->debuglist != NULL);
for (i = 0; i < DEBUG_TABLE_COUNT; i++) {
}
}
- sdallocx(ctx->debuglist,
- (DEBUG_TABLE_COUNT * sizeof(debuglist_t)), 0);
+ free(ctx->debuglist);
}
#endif /* if ISC_MEM_TRACKLINES */
isc_nm_accept_cb_t accept_cb, void *accept_cbarg, int backlog,
isc_quota_t *quota, isc_nmsocket_t **sockp) {
isc_nmsocket_t *sock = NULL;
- size_t children_size = 0;
uv_os_sock_t fd = -1;
isc_result_t result = ISC_R_UNSET;
isc__networker_t *worker = &mgr->workers[0];
sock->nchildren = (workers == ISC_NM_LISTEN_ALL) ? (uint32_t)mgr->nloops
: workers;
- children_size = sock->nchildren * sizeof(sock->children[0]);
- sock->children = isc_mem_getx(worker->mctx, children_size,
- ISC_MEM_ZERO);
+ sock->children = isc_mem_cget(worker->mctx, sock->nchildren,
+ sizeof(sock->children[0]));
isc__nmsocket_barrier_init(sock);
isc_nm_recv_cb_t cb, void *cbarg, isc_nmsocket_t **sockp) {
isc_result_t result = ISC_R_UNSET;
isc_nmsocket_t *sock = NULL;
- size_t children_size = 0;
uv_os_sock_t fd = -1;
isc__networker_t *worker = &mgr->workers[0];
sock->nchildren = (workers == ISC_NM_LISTEN_ALL) ? (uint32_t)mgr->nloops
: workers;
- children_size = sock->nchildren * sizeof(sock->children[0]);
- sock->children = isc_mem_getx(worker->mctx, children_size,
- ISC_MEM_ZERO);
+ sock->children = isc_mem_cget(worker->mctx, sock->nchildren,
+ sizeof(sock->children[0]));
isc__nmsocket_barrier_init(sock);
RUNTIME_CHECK(OPENSSL_init_ssl(opts, NULL) == 1);
#else
nlocks = CRYPTO_num_locks();
- locks = isc_mem_cgetx(isc__tls_mctx, nlocks, sizeof(locks[0]),
- ISC_MEM_ZERO);
+ locks = isc_mem_cget(isc__tls_mctx, nlocks, sizeof(locks[0]));
isc_mutexblock_init(locks, nlocks);
CRYPTO_set_locking_callback(isc__tls_lock_callback);
CRYPTO_THREADID_set_callback(isc__tls_set_thread_id);
if (symtab == NULL) {
return (ISC_R_NOMEMORY);
}
- symtab->table = malloc(size * sizeof(eltlist_t));
+ symtab->table = calloc(size, sizeof(eltlist_t));
if (symtab->table == NULL) {
free(symtab);
return (ISC_R_NOMEMORY);
}
/* Grow stack? */
if (stackcount == pushed) {
- void *newstack;
- uint32_t newlen = stackcount + 16;
- size_t newsize, oldsize;
-
- newsize = newlen * sizeof(*stack);
- oldsize = stackcount * sizeof(*stack);
- newstack = isc_mem_get(mctx, newsize);
- if (stackcount != 0) {
- memmove(newstack, stack, oldsize);
- isc_mem_put(mctx, stack, oldsize);
- }
- stack = newstack;
- stackcount = newlen;
+ stack = isc_mem_creget(mctx, stack, stackcount,
+ stackcount + 16,
+ sizeof(stack[0]));
+ stackcount += 16;
}
stack[pushed++] = UNCONST(cfg_list_next(element));
goto newlist;
void *pval = NULL;
uint32_t ival = ~0U;
dns_qp_t *qp = NULL;
- size_t bytes = ITEM_COUNT * sizeof(*item);
uint64_t start;
start = isc_time_monotonic();
- item = isc_mem_allocatex(mctx, bytes, ISC_MEM_ZERO);
+ item = isc_mem_callocate(mctx, ITEM_COUNT, sizeof(*item));
/* ensure there are no duplicate names */
dns_qp_create(mctx, &item_methods, NULL, &qp);
double time = (double)(isc_time_monotonic() - start) / NS_PER_SEC;
printf("%f sec to create %zu items, %f/sec %zu bytes\n", time,
- ITEM_COUNT, ITEM_COUNT / time, bytes);
+ ITEM_COUNT, ITEM_COUNT / time, ITEM_COUNT * sizeof(*item));
}
static void