From 2f819526585d8143ef12ee103e1ade33f7d6b2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 5 Aug 2025 18:05:52 +0200 Subject: [PATCH] Pass 'mctx' instead of 'db' to dns_slabheader_new() The slabheader doesn't directly attach or link to 'db' anymore. Pass only the memory context needed to create the slab header to make the lack of relation ship more prominent. Also don't call dns_slabheader_reset() from dns_slabheader_new(), it has no added value. --- lib/dns/include/dns/rdataslab.h | 6 +++--- lib/dns/qpcache.c | 2 +- lib/dns/qpzone.c | 4 ++-- lib/dns/rdataslab.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/dns/include/dns/rdataslab.h b/lib/dns/include/dns/rdataslab.h index c5e61c3b92..b93619f600 100644 --- a/lib/dns/include/dns/rdataslab.h +++ b/lib/dns/include/dns/rdataslab.h @@ -295,14 +295,14 @@ void dns_slabheader_reset(dns_slabheader_t *h, dns_dbnode_t *node); /*%< * Reset an rdataslab header 'h' so it can be used to store data in - * database 'db' and node 'node'. + * database node 'node'. */ dns_slabheader_t * -dns_slabheader_new(dns_db_t *db, dns_dbnode_t *node); +dns_slabheader_new(isc_mem_t *mctx, dns_dbnode_t *node); /*%< * Allocate memory for an rdataslab header and initialize it for use - * in database 'db'/node 'node'. + * in database node 'node'. */ void diff --git a/lib/dns/qpcache.c b/lib/dns/qpcache.c index 8a2cd03879..93ae06cd18 100644 --- a/lib/dns/qpcache.c +++ b/lib/dns/qpcache.c @@ -3163,7 +3163,7 @@ qpcache_deleterdataset(dns_db_t *db, dns_dbnode_t *node, return ISC_R_NOTIMPLEMENTED; } - newheader = dns_slabheader_new(db, node); + newheader = dns_slabheader_new(db->mctx, node); newheader->typepair = DNS_TYPEPAIR_VALUE(type, covers); setttl(newheader, 0); atomic_init(&newheader->attributes, attributes); diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 76eb96c9d5..10d1065e12 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -5026,7 +5026,7 @@ qpzone_subtractrdataset(dns_db_t *db, dns_dbnode_t *dbnode, * add a nonexistent header instead. */ dns_slabheader_destroy(&newheader); - newheader = dns_slabheader_new((dns_db_t *)qpdb, + newheader = dns_slabheader_new(db->mctx, (dns_dbnode_t *)node); newheader->ttl = 0; newheader->typepair = topheader->typepair; @@ -5110,7 +5110,7 @@ qpzone_deleterdataset(dns_db_t *db, dns_dbnode_t *dbnode, return ISC_R_NOTIMPLEMENTED; } - newheader = dns_slabheader_new(db, (dns_dbnode_t *)node); + newheader = dns_slabheader_new(db->mctx, (dns_dbnode_t *)node); newheader->typepair = DNS_TYPEPAIR_VALUE(type, covers); newheader->ttl = 0; atomic_init(&newheader->attributes, DNS_SLABHEADERATTR_NONEXISTENT); diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c index 35645b66e3..c175f449a0 100644 --- a/lib/dns/rdataslab.c +++ b/lib/dns/rdataslab.c @@ -886,14 +886,14 @@ dns_slabheader_reset(dns_slabheader_t *h, dns_dbnode_t *node) { } dns_slabheader_t * -dns_slabheader_new(dns_db_t *db, dns_dbnode_t *node) { +dns_slabheader_new(isc_mem_t *mctx, dns_dbnode_t *node) { dns_slabheader_t *h = NULL; - h = isc_mem_get(db->mctx, sizeof(*h)); + h = isc_mem_get(mctx, sizeof(*h)); *h = (dns_slabheader_t){ .link = ISC_LINK_INITIALIZER, + .node = node, }; - dns_slabheader_reset(h, node); return h; }