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

Do extra manual isc_mem_cget() conversions

Some of the cases weren't caught by the coccinelle and there were some
places where cget+memmove() could get converted to simple creget().
This commit is contained in:
Ondřej Surý
2023-08-23 10:00:12 +02:00
parent 89fcb6f897
commit 55c29b8d83
22 changed files with 95 additions and 191 deletions

View File

@@ -25,6 +25,7 @@
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/netaddr.h>
#include <isc/overflow.h>
#include <isc/result.h>
#include <isc/util.h>
@@ -259,7 +260,7 @@ expand_entries(dns_rrl_t *rrl, int newsize) {
}
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;
@@ -298,7 +299,8 @@ free_old_hash(dns_rrl_t *rrl) {
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;
}
@@ -323,7 +325,8 @@ expand_rrl_hash(dns_rrl_t *rrl, isc_stdtime_t now) {
}
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;
@@ -1321,13 +1324,15 @@ dns_rrl_view_destroy(dns_view_t *view) {
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));