summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@fingolfin.org>2022-01-17 01:01:01 +0000
committerRobert Mustacchi <rm@fingolfin.org>2022-01-30 15:22:24 +0000
commit597b30361cb132283d94270df35d0536cf12895f (patch)
tree539e0f0b40ab5f1289895d0f5ca60a996373c134 /usr
parent9023fe694e5cc93a381708677f172a85f250caa5 (diff)
downloadillumos-gate-597b30361cb132283d94270df35d0536cf12895f.tar.gz
9855 list_next/list_prev needs a bit more detail
Reviewed by: Richard Lowe <richlowe@richlowe.net> Reviewed by: Andy Fiddaman <andy@omnios.org> Approved by: Gordon Ross <gordon.w.ross@gmail.com>
Diffstat (limited to 'usr')
-rw-r--r--usr/src/man/man9f/list_create.9f20
1 files changed, 20 insertions, 0 deletions
diff --git a/usr/src/man/man9f/list_create.9f b/usr/src/man/man9f/list_create.9f
index a25f4feab7..44fb617163 100644
--- a/usr/src/man/man9f/list_create.9f
+++ b/usr/src/man/man9f/list_create.9f
@@ -234,6 +234,26 @@ and
.Fn list_prev
functions return the next or previous item in the list, relative to the named
reference item which must be linked on the list.
+If the referenced item is either the last entry in the list for
+.Fn list_next
+or the first entry in the list for
+.Fn list_prev ,
+then the functions will return
+.Dv NULL .
+This is useful for iterating over a list with the following pattern:
+.Bd -literal -offset indent
+list_t list_t;
+\&...
+for (foo_t *foo = list_head(&list_t); foo != NULL;
+ foo = list_next(&list_t, foo)) {
+ /* Process each entry of the list */
+}
+
+for (foo_t *foo = list_tail(&list_t); foo != NULL;
+ foo = list_prev(&list_t, foo)) {
+ /* Same thing, but in reverse */
+}
+.Ed
.Pp
The
.Fn list_is_empty