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.
This commit is contained in:
alfred 2002-08-05 05:18:43 +00:00
parent 0a5393ffc8
commit e7bcbc4dbf

View File

@ -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)