mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
Look for the next matching tuple in a separate function
Extract the portion of the do-while loop responsible for finding the next tuple with the same name and type into a separate function to improve code clarity.
This commit is contained in:
@@ -7288,6 +7288,26 @@ need_nsec_chain(dns_db_t *db, dns_dbversion_t *ver,
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*%
|
||||||
|
* Given a tuple which is part of a diff, return a pointer to the next tuple in
|
||||||
|
* that diff which has the same name and type (or NULL if no such tuple is
|
||||||
|
* found).
|
||||||
|
*/
|
||||||
|
static dns_difftuple_t *
|
||||||
|
find_next_matching_tuple(dns_difftuple_t *cur) {
|
||||||
|
dns_difftuple_t *next = cur;
|
||||||
|
|
||||||
|
while ((next = ISC_LIST_NEXT(next, link)) != NULL) {
|
||||||
|
if (cur->rdata.type == next->rdata.type &&
|
||||||
|
dns_name_equal(&cur->name, &next->name))
|
||||||
|
{
|
||||||
|
return (next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* Remove all tuples with the same name and type as 'cur' from 'src' and append
|
* Remove all tuples with the same name and type as 'cur' from 'src' and append
|
||||||
* them to 'dst'.
|
* them to 'dst'.
|
||||||
@@ -7295,11 +7315,7 @@ need_nsec_chain(dns_db_t *db, dns_dbversion_t *ver,
|
|||||||
static void
|
static void
|
||||||
move_matching_tuples(dns_difftuple_t *cur, dns_diff_t *src, dns_diff_t *dst) {
|
move_matching_tuples(dns_difftuple_t *cur, dns_diff_t *src, dns_diff_t *dst) {
|
||||||
do {
|
do {
|
||||||
dns_difftuple_t *next = ISC_LIST_NEXT(cur, link);
|
dns_difftuple_t *next = find_next_matching_tuple(cur);
|
||||||
while (next != NULL &&
|
|
||||||
(cur->rdata.type != next->rdata.type ||
|
|
||||||
!dns_name_equal(&cur->name, &next->name)))
|
|
||||||
next = ISC_LIST_NEXT(next, link);
|
|
||||||
ISC_LIST_UNLINK(src->tuples, cur, link);
|
ISC_LIST_UNLINK(src->tuples, cur, link);
|
||||||
dns_diff_appendminimal(dst, &cur);
|
dns_diff_appendminimal(dst, &cur);
|
||||||
INSIST(cur == NULL);
|
INSIST(cur == NULL);
|
||||||
|
Reference in New Issue
Block a user