diff options
author | Cliff Woolley <jwoolley@apache.org> | 2003-08-13 01:46:12 +0000 |
---|---|---|
committer | Cliff Woolley <jwoolley@apache.org> | 2003-08-13 01:46:12 +0000 |
commit | bd9b81bbaca7c3514b6527f1551ed114375c1339 (patch) | |
tree | 07aeb792aeb5d36d787b4b8d560243c4f2529238 /include/apr_ring.h | |
parent | 075a9047b3864aa88fc683a285c06ef79353a253 (diff) | |
download | apr-bd9b81bbaca7c3514b6527f1551ed114375c1339.tar.gz |
seemed like a handy tool.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@64585 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include/apr_ring.h')
-rw-r--r-- | include/apr_ring.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/apr_ring.h b/include/apr_ring.h index 25a1f20be..6bb935bc3 100644 --- a/include/apr_ring.h +++ b/include/apr_ring.h @@ -482,10 +482,14 @@ #ifdef APR_RING_DEBUG #include <stdio.h> +#include <assert.h> + #define APR_RING_CHECK_ONE(msg, ptr) \ fprintf(stderr, "*** %s %p\n", msg, ptr) + #define APR_RING_CHECK(hp, elem, link, msg) \ APR_RING_CHECK_ELEM(APR_RING_SENTINEL(hp, elem, link), elem, link, msg) + #define APR_RING_CHECK_ELEM(ep, elem, link, msg) do { \ struct elem *start = (ep); \ struct elem *here = start; \ @@ -512,6 +516,17 @@ } while (here != start); \ fprintf(stderr, "*** ring check end\n"); \ } while (0) + +#define APR_RING_CHECK_CONSISTENCY(hp, elem, link) do { \ + struct elem *start = APR_RING_SENTINEL(hp, elem, link); \ + struct elem *here = start; \ + do { \ + assert(APR_RING_PREV(APR_RING_NEXT(here, link), link) == here); \ + assert(APR_RING_NEXT(APR_RING_PREV(here, link), link) == here); \ + here = APR_RING_NEXT(here, link); \ + } while (here != start); \ + } while (0) + #else /** * Print a single pointer value to STDERR @@ -532,6 +547,16 @@ */ #define APR_RING_CHECK(hp, elem, link, msg) /** + * Loops around a ring and checks all the pointers for consistency. Pops + * an assertion if any inconsistency is found. Same idea as APR_RING_CHECK() + * except that it's silent if all is well. + * (This is a no-op unless APR_RING_DEBUG is defined.) + * @param hp 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_CHECK_CONSISTENCY(hp, elem, link) +/** * Dump all ring pointers to STDERR, starting with the given element and * looping all the way around the ring back to that element. Aborts if * an inconsistency is found. |