apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r555640 - /apr/apr/trunk/include/apr_ring.h
Date Thu, 12 Jul 2007 14:23:14 GMT
Author: davi
Date: Thu Jul 12 07:23:13 2007
New Revision: 555640

URL: http://svn.apache.org/viewvc?view=rev&rev=555640
Log:
Add helper macros for ring walking (APR_RING_FOREACH and APR_RING_FOREACH_SAFE).

Modified:
    apr/apr/trunk/include/apr_ring.h

Modified: apr/apr/trunk/include/apr_ring.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_ring.h?view=diff&rev=555640&r1=555639&r2=555640
==============================================================================
--- apr/apr/trunk/include/apr_ring.h (original)
+++ apr/apr/trunk/include/apr_ring.h Thu Jul 12 07:23:13 2007
@@ -377,6 +377,30 @@
 #define APR_RING_REMOVE(ep, link)					\
     APR_RING_UNSPLICE((ep), (ep), link)
 
+/**
+ * Iterate over a ring
+ * @param ep The current element
+ * @param head The head of the ring
+ * @param elem The name of the element struct
+ * @param link The name of the APR_RING_ENTRY in the element struct
+ */
+#define APR_RING_FOREACH(ep, head, elem, link)                          \
+    for (ep = APR_RING_FIRST(head);                                     \
+         ep != APR_RING_SENTINEL(head, elem, link);                     \
+         ep = APR_RING_NEXT(ep, link))
+
+/**
+ * Iterate over a ring safe against removal of the current element
+ * @param ep1 The current element
+ * @param ep2 Iteration cursor
+ * @param head The head of the ring
+ * @param elem The name of the element struct
+ * @param link The name of the APR_RING_ENTRY in the element struct
+ */
+#define APR_RING_FOREACH_SAFE(ep1, ep2, head, elem, link)               \
+    for (ep1 = APR_RING_FIRST(head), ep2 = APR_RING_NEXT(ep1, link);    \
+         ep1 != APR_RING_SENTINEL(head, elem, link);                    \
+         ep1 = ep2, ep2 = APR_RING_NEXT(ep1, link))
 
 /* Debugging tools: */
 



Mime
View raw message