diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-12-16 21:08:21 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-12-16 21:08:21 +0000 |
commit | 3a97292e159afb28cb76d16899c36d4c360a7752 (patch) | |
tree | 0cb560b2862be94458ca69f9c6b75f4d6f137e36 /sys | |
parent | 1797fd7b7a5f9823a70b63fa8b4ea907e8bacf08 (diff) |
Add SLIST_FOREACH_PREVPTR and SLIST_REMOVE_NEXT. SLIST_FOREACH_PREVPTR
is like SLIST_FOREACH but it saves a pointer to the previous element.
SLIST_REMOVE_NEXT will remove the element *after* the one passed in.
SLIST_FOREACH_PREVPTR is from FreeBSD; SLIST_REMOVE_NEXT was suggested
by canacar@; man page additions by yours truly. OK deraadt@ (grudgingly)
and man page changes OK jmc@.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/sys/queue.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/sys/queue.h b/sys/sys/queue.h index 9b2b8dd5788..7d5fb83c455 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.h,v 1.23 2003/06/02 23:28:21 millert Exp $ */ +/* $OpenBSD: queue.h,v 1.24 2003/12/16 21:08:20 millert Exp $ */ /* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ /* @@ -111,6 +111,11 @@ struct { \ (var) != SLIST_END(head); \ (var) = SLIST_NEXT(var, field)) +#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ + for ((varp) = &SLIST_FIRST((head)); \ + ((var) = *(varp)) != SLIST_END(head); \ + (varp) = &SLIST_NEXT((var), field)) + /* * Singly-linked List functions. */ @@ -128,6 +133,10 @@ struct { \ (head)->slh_first = (elm); \ } while (0) +#define SLIST_REMOVE_NEXT(head, elm, field) do { \ + (elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \ +} while (0) + #define SLIST_REMOVE_HEAD(head, field) do { \ (head)->slh_first = (head)->slh_first->field.sle_next; \ } while (0) |