Add macro RB_FOREACH_SAFE(), which accepts an additional argument
specifying a temporary tree node pointer. It may be used in a similar way to the *_SAFE() macros in <sys/queue.h>.
This commit is contained in:
parent
138f7e4b30
commit
c494cd1e77
@ -737,6 +737,11 @@ name##_RB_MINMAX(struct name *head, int val) \
|
||||
(x) != NULL; \
|
||||
(x) = name##_RB_NEXT(x))
|
||||
|
||||
#define RB_FOREACH_SAFE(x, name, head, y) \
|
||||
for ((x) = RB_MIN(name, head); \
|
||||
(x) != NULL && ((y) = name##_RB_NEXT(x)); \
|
||||
(x) = (y))
|
||||
|
||||
#define RB_FOREACH_REVERSE(x, name, head) \
|
||||
for ((x) = RB_MAX(name, head); \
|
||||
(x) != NULL; \
|
||||
|
Loading…
Reference in New Issue
Block a user