From: Alessio Podda Date: Mon, 22 Dec 2025 13:43:40 +0000 (+0100) Subject: Return node pointer in step X-Git-Tag: v9.21.19~27^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=169cbe84319e7afb231144144b1279c462dd5fbb;p=thirdparty%2Fbind9.git Return node pointer in step Part of an refactor to eliminate intermediate copies in qpzone_find. --- diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index e73f06ef7db..a9d8f56854c 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -2641,7 +2641,9 @@ typedef enum { FORWARD, BACK } direction_t; */ static bool step(qpz_search_t *search, dns_qpiter_t *it, direction_t direction, - dns_name_t *nextname) { + qpznode_t **node_p) { + REQUIRE(node_p != NULL && *node_p == NULL); + qpznode_t *node = NULL, *previous_node = NULL; isc_result_t result = ISC_R_SUCCESS; @@ -2671,7 +2673,7 @@ step(qpz_search_t *search, dns_qpiter_t *it, direction_t direction, if (result == ISC_R_SUCCESS) { if (previous_node != NULL) { - dns_name_copy(&previous_node->name, nextname); + *node_p = previous_node; } return true; } @@ -2681,8 +2683,7 @@ step(qpz_search_t *search, dns_qpiter_t *it, direction_t direction, static bool activeempty(qpz_search_t *search, dns_qpiter_t *it, const dns_name_t *current) { - dns_fixedname_t fnext; - dns_name_t *next = dns_fixedname_initname(&fnext); + qpznode_t *next_node = NULL; /* * The iterator is currently pointed at the predecessor @@ -2697,17 +2698,15 @@ activeempty(qpz_search_t *search, dns_qpiter_t *it, const dns_name_t *current) { /* An ENT at the end of the zone is impossible */ return false; } - return step(search, it, FORWARD, next) && - dns_name_issubdomain(next, current); + return step(search, it, FORWARD, &next_node) && + dns_name_issubdomain(&next_node->name, current); } static bool wildcard_blocked(qpz_search_t *search, const dns_name_t *qname, dns_name_t *wname) { isc_result_t result; - dns_fixedname_t fnext; - dns_fixedname_t fprev; - dns_name_t *next = NULL, *prev = NULL; + qpznode_t *next_node = NULL, *prev_node = NULL; dns_name_t name; dns_name_t rname; dns_name_t tname; @@ -2719,8 +2718,6 @@ wildcard_blocked(qpz_search_t *search, const dns_name_t *qname, dns_name_init(&name); dns_name_init(&tname); dns_name_init(&rname); - next = dns_fixedname_initname(&fnext); - prev = dns_fixedname_initname(&fprev); /* * The qname seems to have matched a wildcard, but we @@ -2734,13 +2731,13 @@ wildcard_blocked(qpz_search_t *search, const dns_name_t *qname, * data. */ it = search->iter; - check_prev = step(search, &it, BACK, prev); + check_prev = step(search, &it, BACK, &prev_node); /* Now reset the iterator and look for a successor with data. */ it = search->iter; result = dns_qpiter_next(&it, NULL, NULL); if (result == ISC_R_SUCCESS) { - check_next = step(search, &it, FORWARD, next); + check_next = step(search, &it, FORWARD, &next_node); } if (!check_prev && !check_next) { @@ -2757,8 +2754,10 @@ wildcard_blocked(qpz_search_t *search, const dns_name_t *qname, dns_name_getlabelsequence(wname, 1, n - 1, &tname); do { - if ((check_prev && dns_name_issubdomain(prev, &rname)) || - (check_next && dns_name_issubdomain(next, &rname))) + if ((check_prev && + dns_name_issubdomain(&prev_node->name, &rname)) || + (check_next && + dns_name_issubdomain(&next_node->name, &rname))) { return true; }