summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
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