diff options
author | bms <bms@FreeBSD.org> | 2008-12-24 19:57:22 +0000 |
---|---|---|
committer | bms <bms@FreeBSD.org> | 2008-12-24 19:57:22 +0000 |
commit | ec227891ebf88532712b2408f0fa839e0347afe1 (patch) | |
tree | 45fb90fbef946c78894c3fe2a34017e4bd92c449 /sys/sys/tree.h | |
parent | 953a7479f360a3e009213c774a21d375976a8866 (diff) | |
download | FreeBSD-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/sys/tree.h')
-rw-r--r-- | sys/sys/tree.h | 5 |
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; \ |