diff options
Diffstat (limited to 'man3/slist.3')
-rw-r--r-- | man3/slist.3 | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/man3/slist.3 b/man3/slist.3 index 045a3f629..98ce85937 100644 --- a/man3/slist.3 +++ b/man3/slist.3 @@ -5,7 +5,7 @@ .\" SPDX-License-Identifier: BSD-3-Clause .\" .\" -.TH SLIST 3 2022-10-30 "Linux man-pages 6.03" +.TH SLIST 3 2023-05-03 "Linux man-pages 6.05.01" .SH NAME SLIST_EMPTY, SLIST_ENTRY, @@ -241,9 +241,9 @@ structure, respectively. returns an initializer that can be assigned to the list .IR head . .SH STANDARDS -Not in POSIX.1, POSIX.1-2001, or POSIX.1-2008. -Present on the BSDs -(SLIST macros first appeared in 4.4BSD). +BSD. +.SH HISTORY +4.4BSD. .SH BUGS .BR SLIST_FOREACH () doesn't allow @@ -263,53 +263,53 @@ without interfering with the traversal. #include <stdio.h> #include <stdlib.h> #include <sys/queue.h> - +\& struct entry { int data; SLIST_ENTRY(entry) entries; /* Singly linked list */ }; - +\& SLIST_HEAD(slisthead, entry); - +\& int main(void) { struct entry *n1, *n2, *n3, *np; struct slisthead head; /* Singly linked list head */ - +\& SLIST_INIT(&head); /* Initialize the queue */ - +\& n1 = malloc(sizeof(struct entry)); /* Insert at the head */ SLIST_INSERT_HEAD(&head, n1, entries); - +\& n2 = malloc(sizeof(struct entry)); /* Insert after */ SLIST_INSERT_AFTER(n1, n2, entries); - +\& SLIST_REMOVE(&head, n2, entry, entries);/* Deletion */ free(n2); - +\& n3 = SLIST_FIRST(&head); SLIST_REMOVE_HEAD(&head, entries); /* Deletion from the head */ free(n3); - +\& for (unsigned int i = 0; i < 5; i++) { n1 = malloc(sizeof(struct entry)); SLIST_INSERT_HEAD(&head, n1, entries); n1\->data = i; } - +\& /* Forward traversal */ SLIST_FOREACH(np, &head, entries) printf("%i\en", np\->data); - +\& while (!SLIST_EMPTY(&head)) { /* List deletion */ n1 = SLIST_FIRST(&head); SLIST_REMOVE_HEAD(&head, entries); free(n1); } SLIST_INIT(&head); - +\& exit(EXIT_SUCCESS); } .EE |