]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Return node pointer in step
authorAlessio Podda <alessio@isc.org>
Mon, 22 Dec 2025 13:43:40 +0000 (14:43 +0100)
committerOndřej Surý <ondrej@isc.org>
Thu, 12 Feb 2026 16:36:48 +0000 (17:36 +0100)
Part of an refactor to eliminate intermediate copies in qpzone_find.

lib/dns/qpzone.c

index e73f06ef7db2e5956733a641c842ac2a6f11d9ee..a9d8f56854cc5e9b0d08017d26a14ff2f4247d7e 100644 (file)
@@ -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;
                }