diff options
author | Davi Arnaut <davi@apache.org> | 2007-07-12 14:23:13 +0000 |
---|---|---|
committer | Davi Arnaut <davi@apache.org> | 2007-07-12 14:23:13 +0000 |
commit | a45f3bbb010a8bca5796709c6e30beaf07fb01b8 (patch) | |
tree | 2499ca084031a5e0b923d89516bdf016871639d0 /include/apr_ring.h | |
parent | e279bd3015c50aa5a43e59851063583c7c526842 (diff) | |
download | apr-a45f3bbb010a8bca5796709c6e30beaf07fb01b8.tar.gz |
Add helper macros for ring walking (APR_RING_FOREACH and APR_RING_FOREACH_SAFE).
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@555640 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include/apr_ring.h')
-rw-r--r-- | include/apr_ring.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/apr_ring.h b/include/apr_ring.h index eab1e69a8..a796816dc 100644 --- a/include/apr_ring.h +++ b/include/apr_ring.h @@ -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: */ |