svn commit: r186479 - head/sys/sys

Bruce M Simpson bms at FreeBSD.org
Wed Dec 24 19:57:22 UTC 2008


Author: bms
Date: Wed Dec 24 19:57:22 2008
New Revision: 186479
URL: http://svn.freebsd.org/changeset/base/186479

Log:
  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>.

Modified:
  head/sys/sys/tree.h

Modified: head/sys/sys/tree.h
==============================================================================
--- head/sys/sys/tree.h	Wed Dec 24 11:12:21 2008	(r186478)
+++ head/sys/sys/tree.h	Wed Dec 24 19:57:22 2008	(r186479)
@@ -737,6 +737,11 @@ name##_RB_MINMAX(struct name *head, int 
 	     (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;						\


More information about the svn-src-all mailing list