summaryrefslogtreecommitdiff
path: root/utils/ring.h
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2010-04-08 11:21:50 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2010-04-08 11:21:50 +0000
commit6948496d45f9de4554644346b62421c60c0a340e (patch)
treeca7738f2e75a561fb773bf3ef06c6b36f08619df /utils/ring.h
parent51b27bdf54cc15b3c2ff68ccdfbc4d7aeac47252 (diff)
downloadnetsurf-6948496d45f9de4554644346b62421c60c0a340e.tar.gz
netsurf-6948496d45f9de4554644346b62421c60c0a340e.tar.bz2
Ensure that aborting or releasing hlcache handles will result in nascent retrieval contexts being cleaned up
svn path=/trunk/netsurf/; revision=10298
Diffstat (limited to 'utils/ring.h')
-rw-r--r--utils/ring.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/utils/ring.h b/utils/ring.h
index d6258c240..1dfd23603 100644
--- a/utils/ring.h
+++ b/utils/ring.h
@@ -106,4 +106,32 @@
} while (p != ring); \
} else sizevar = 0
+/*
+ * Ring iteration works as follows:
+ *
+ * RING_ITERATE_START(ringtype, ring, iteratorptr) {
+ * code_using(iteratorptr);
+ * } RING_ITERATE_END(ring, iteratorptr);
+ *
+ * If you want to stop iterating (e.g. you found your answer)
+ * RING_ITERATE_STOP(ring, iteratorptr);
+ * You *MUST* abort the iteration if you do something to modify
+ * the ring such as deleting or adding an element.
+ */
+
+#define RING_ITERATE_START(ringtype, ring, iteratorptr) \
+ if (ring != NULL) { \
+ ringtype *iteratorptr = ring; \
+ do { \
+ do { \
+
+#define RING_ITERATE_STOP(ring, iteratorptr) \
+ goto iteration_end_##ring##_##iteratorptr
+
+#define RING_ITERATE_END(ring, iteratorptr) \
+ } while (false); \
+ } while (iteratorptr != ring); \
+ } \
+ iteration_end_##ring##_##iteratorptr:
+
#endif