mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-17 02:56:51 +00:00
MINOR: ebtree/scope: add a function to find next node from a parent
Several parts of the code need to access the next node but don't start from a node but a tagged parent link. Even eb32sc_next() does this. Let's provide this function to prepare a cleanup for the lookup function.
This commit is contained in:
parent
5274330586
commit
f6ac365d8d
@ -108,22 +108,25 @@ static inline struct eb32sc_node *eb32sc_walk_down_left(eb_troot_t *start, unsig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return next node in the tree, starting with tagged parent <start>, or NULL if none */
|
||||||
|
static inline struct eb32sc_node *eb32sc_next_with_parent(eb_troot_t *start, unsigned long scope)
|
||||||
|
{
|
||||||
|
while (eb_gettag(start) != EB_LEFT)
|
||||||
|
/* Walking up from right branch, so we cannot be below root */
|
||||||
|
start = (eb_root_to_node(eb_untag(start, EB_RGHT)))->node_p;
|
||||||
|
|
||||||
|
/* Note that <t> cannot be NULL at this stage */
|
||||||
|
start = (eb_untag(start, EB_LEFT))->b[EB_RGHT];
|
||||||
|
if (eb_clrtag(start) == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return eb32sc_walk_down_left(start, scope);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return next node in the tree, or NULL if none */
|
/* Return next node in the tree, or NULL if none */
|
||||||
static inline struct eb32sc_node *eb32sc_next(struct eb32sc_node *eb32, unsigned long scope)
|
static inline struct eb32sc_node *eb32sc_next(struct eb32sc_node *eb32, unsigned long scope)
|
||||||
{
|
{
|
||||||
struct eb_node *node = &eb32->node;
|
return eb32sc_next_with_parent(eb32->node.leaf_p, scope);
|
||||||
eb_troot_t *t = node->leaf_p;
|
|
||||||
|
|
||||||
while (eb_gettag(t) != EB_LEFT)
|
|
||||||
/* Walking up from right branch, so we cannot be below root */
|
|
||||||
t = (eb_root_to_node(eb_untag(t, EB_RGHT)))->node_p;
|
|
||||||
|
|
||||||
/* Note that <t> cannot be NULL at this stage */
|
|
||||||
t = (eb_untag(t, EB_LEFT))->b[EB_RGHT];
|
|
||||||
if (eb_clrtag(t) == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return eb32sc_walk_down_left(t, scope);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return leftmost node in the tree, or NULL if none */
|
/* Return leftmost node in the tree, or NULL if none */
|
||||||
|
Loading…
Reference in New Issue
Block a user