You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by da...@apache.org on 2007/07/12 16:23:14 UTC

svn commit: r555640 - /apr/apr/trunk/include/apr_ring.h

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: */
 



Re: svn commit: r555640 - /apr/apr/trunk/include/apr_ring.h

Posted by Davi Arnaut <da...@haxent.com.br>.
Paul Querna wrote:
> davi@apache.org wrote:
>> 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).
> 
> I'm not sure if we want to keep these or not.
> 
> I don't have anything wrong with them, but didn't we remove the _FOREACH
> macros from brigades in 0.9->1.x?

Sorry, I didn't saw the old commits that removed the macros.

> It seems odd to remove them from one API, and to add them here....
> 
> Thoughts?
> 

IMHO, the reasoning behind the removal was weak. We shouldn't penalize
everyone for the sake of the few that get it wrong.

--
Davi Arnaut

Re: svn commit: r555640 - /apr/apr/trunk/include/apr_ring.h

Posted by Paul Querna <ch...@force-elite.com>.
davi@apache.org wrote:
> 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).

I'm not sure if we want to keep these or not.

I don't have anything wrong with them, but didn't we remove the _FOREACH
macros from brigades in 0.9->1.x?

It seems odd to remove them from one API, and to add them here....

Thoughts?

-Paul