[PATCH 8/8] stailq.3: Add remaining details to complete the page

Alejandro Colomar colomar.6.4.3@gmail.com
Sat Oct 24 22:21:16 GMT 2020


Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
---
 man3/stailq.3 | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/man3/stailq.3 b/man3/stailq.3
index 0abacd824..2896d27c9 100644
--- a/man3/stailq.3
+++ b/man3/stailq.3
@@ -51,6 +51,7 @@ STAILQ_REMOVE,
 .\"STAILQ_REMOVE_AFTER,
 STAILQ_REMOVE_HEAD,
 .\"STAILQ_SWAP
+\- implementation of a singly-linked tail queue
 .SH SYNOPSIS
 .nf
 .B #include <sys/queue.h>
@@ -100,6 +101,8 @@ STAILQ_REMOVE_HEAD,
 .\" .BI "                STAILQ_ENTRY " NAME ");"
 .fi
 .SH DESCRIPTION
+These macros define and operate on singly-linked tail queues.
+.PP
 In the macro definitions,
 .I TYPE
 is the name of a user-defined structure,
@@ -292,11 +295,38 @@ from the tail queue.
 .\" and
 .\" .IR head2 .
 .SH RETURN VALUE
+.BR STAILQ_EMPTY ()
+returns nonzero if the queue is empty,
+and zero if the queue contains at least one entry.
+.PP
+.BR STAILQ_FIRST (),
+and
+.BR STAILQ_NEXT ()
+return a pointer to the first or next
+.I STAILQ_ENTRY
+structure, respectively.
+.PP
+.BR STAILQ_HEAD_INITIALIZER ()
+returns an initializer that can be assigned to the queue
+.IR head .
 .SH CONFORMING TO
 Not in POSIX.1, POSIX.1-2001 or POSIX.1-2008.
 Present on the BSDs
 (STAILQ macros first appeared in 4.4BSD).
 .SH BUGS
+The macro
+.BR STAILQ_FOREACH ()
+doesn't allow
+.I var
+to be removed or freed within the loop,
+as it would interfere with the traversal.
+The macro
+.BR STAILQ_FOREACH_SAFE (),
+which is present on the BSDs but is not present in glibc,
+fixes this limitation by allowing
+.I var
+to safely be removed from the list and freed from within the loop
+without interfering with the traversal.
 .SH EXAMPLES
 .EX
 #include <stddef.h>
-- 
2.28.0



More information about the Libc-alpha mailing list