summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbms <bms@FreeBSD.org>2008-12-24 19:57:22 +0000
committerbms <bms@FreeBSD.org>2008-12-24 19:57:22 +0000
commitec227891ebf88532712b2408f0fa839e0347afe1 (patch)
tree45fb90fbef946c78894c3fe2a34017e4bd92c449 /sys
parent953a7479f360a3e009213c774a21d375976a8866 (diff)
downloadFreeBSD-src-ec227891ebf88532712b2408f0fa839e0347afe1.zip
FreeBSD-src-ec227891ebf88532712b2408f0fa839e0347afe1.tar.gz
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>.
Diffstat (limited to 'sys')
-rw-r--r--sys/sys/tree.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/sys/tree.h b/sys/sys/tree.h
index 54ea6da..44c0c99 100644
--- a/sys/sys/tree.h
+++ b/sys/sys/tree.h
@@ -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; \
OpenPOWER on IntegriCloud