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:
Bruce M Simpson 2008-12-24 19:57:22 +00:00
parent 138f7e4b30
commit c494cd1e77

View File

@ -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; \