summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2002-08-05 05:18:43 +0000
committeralfred <alfred@FreeBSD.org>2002-08-05 05:18:43 +0000
commite7bcbc4dbfb3670fa4b840cd0b67ad74f0ab1239 (patch)
tree639c54fc9eb48349a0f40ef525de62b2dddb589e /sys
parent0a5393ffc8182ca70dacf0825f2e4e91bb10beb6 (diff)
downloadFreeBSD-src-e7bcbc4dbfb3670fa4b840cd0b67ad74f0ab1239.zip
FreeBSD-src-e7bcbc4dbfb3670fa4b840cd0b67ad74f0ab1239.tar.gz
Add a macro for SLIST traversal 'SLIST_FOREACH_PREVPTR',
this macro keeps a pointer to the previous element's next pointer to allow for search and O(1) removal.
Diffstat (limited to 'sys')
-rw-r--r--sys/sys/queue.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index a86fda0..63012d4 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -164,6 +164,11 @@ struct { \
(var); \
(var) = SLIST_NEXT((var), field))
+#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
+ for ((varp) = &SLIST_FIRST((head)); \
+ ((var) = *(varp)) != NULL; \
+ (varp) = &SLIST_NEXT((var), field))
+
#define SLIST_INIT(head) do { \
SLIST_FIRST((head)) = NULL; \
} while (0)
OpenPOWER on IntegriCloud