#define IS_ROOT(node) ((node)->is_root == 1)
#define FINDCALLBACK(node) ((node)->find_callback == 1)
+#define WANTEMPTYDATA_OR_DATA(options, node) \
+ ((options & DNS_RBTFIND_EMPTYDATA) != 0 || DATA(node) != NULL)
+
/*%
* Structure elements from the rbtdb.c, not
* used as part of the rbt.c algorithms.
/*
* This might be the closest enclosing name.
*/
- if (DATA(current) != NULL ||
- (options & DNS_RBTFIND_EMPTYDATA) != 0)
+ if (WANTEMPTYDATA_OR_DATA(options, current)) {
*node = current;
+ }
/*
* Point the chain to the next level. This
* ISC_R_SUCCESS to indicate an exact match.
*/
if (current != NULL && (options & DNS_RBTFIND_NOEXACT) == 0 &&
- (DATA(current) != NULL ||
- (options & DNS_RBTFIND_EMPTYDATA) != 0)) {
+ (WANTEMPTYDATA_OR_DATA(options, current))) {
/*
* Found an exact match.
*/
result = dns_rbt_findnode(rbt, name, foundname, &node, NULL,
options, NULL, NULL);
- if (node != NULL &&
- (DATA(node) != NULL || (options & DNS_RBTFIND_EMPTYDATA) != 0))
+ if (node != NULL && WANTEMPTYDATA_OR_DATA(options, node)) {
*data = DATA(node);
- else
+ } else {
result = ISC_R_NOTFOUND;
+ }
return (result);
}
dns_rbtnode_t *node = root;
root = PARENT(root);
- if (DATA(node) != NULL && rbt->data_deleter != NULL)
+ if (rbt->data_deleter != NULL && DATA(node) != NULL) {
rbt->data_deleter(DATA(node),
rbt->deleter_arg);
+ }
if (unhash)
unhash_node(rbt, node);
/*