diff options
author | bmilekic <bmilekic@FreeBSD.org> | 2003-08-13 18:37:25 +0000 |
---|---|---|
committer | bmilekic <bmilekic@FreeBSD.org> | 2003-08-13 18:37:25 +0000 |
commit | 3fe501b46e30bf978f14392fe7cdebf3da7b324b (patch) | |
tree | 85e6201483b7232cffb42cbf2d27309dc4ad9bb4 /sys/sys | |
parent | 44bb8d5b2ad04cfbe2fcf89e3c209d0cdd38f012 (diff) | |
download | FreeBSD-src-3fe501b46e30bf978f14392fe7cdebf3da7b324b.zip FreeBSD-src-3fe501b46e30bf978f14392fe7cdebf3da7b324b.tar.gz |
Add LIST_FOREACH_SAFE, which is like LIST_FOREACH but allows you
to walk the list and remove the current item and destroy/free it.
Alexander Kabaev will likely do the equivalent for the other list
types, but I just happened to have this one sitting in a local
non-FreeBSD tree already.
Diffstat (limited to 'sys/sys')
-rw-r--r-- | sys/sys/queue.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/sys/queue.h b/sys/sys/queue.h index 63012d4..a06f084 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -325,6 +325,13 @@ struct { \ (var); \ (var) = LIST_NEXT((var), field)) +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = LIST_FIRST((head)), \ + (var) != NULL ? (tvar) = LIST_NEXT((var), field) : NULL; \ + (var) != NULL; \ + (var) = (tvar), \ + (var) != NULL ? (tvar) = LIST_NEXT((var), field) : NULL) + #define LIST_INIT(head) do { \ LIST_FIRST((head)) = NULL; \ } while (0) |