tailq.3: Add remaining details to complete the page

Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Alejandro Colomar 2020-10-25 10:36:50 +01:00 committed by Michael Kerrisk
parent ace2899780
commit ec99c74df3
1 changed files with 37 additions and 0 deletions

View File

@ -55,6 +55,7 @@ TAILQ_NEXT,
TAILQ_PREV,
TAILQ_REMOVE
.\"TAILQ_SWAP
\- implementation of a doubly-linked tail queue
.SH SYNOPSIS
.nf
.B #include sys/queue.h
@ -110,6 +111,7 @@ TAILQ_REMOVE
.\" .PP
.\" .BI "void TAILQ_SWAP(TAILQ_HEAD *" head1 ", TAILQ_HEAD *" head2 ", TYPE, TAILQ_ENTRY " NAME ");"
.SH DESCRIPTION
These macros define and operate on doubly-linked tail queues.
.PP
In the macro definitions,
.I TYPE
@ -336,11 +338,44 @@ from the tail queue.
.\" and
.\" .IR head2 .
.SH RETURN VALUE
.BR TAILQ_EMPTY ()
returns nonzero if the queue is empty,
and zero if the queue contains at least one entry.
.PP
.BR TAILQ_FIRST (),
.BR TAILQ_LAST (),
.BR TAILQ_NEXT (),
and
.BR TAILQ_PREV ()
return a pointer to the first, last, next or previous
.I TYPE
structure, respectively.
.PP
.BR TAILQ_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.
(TAILQ functions first appeared in 4.4BSD).
.SH BUGS
The macros
.BR TAILQ_FOREACH ()
and
.BR TAILQ_FOREACH_REVERSE ()
don't allow
.I var
to be removed or freed within the loop,
as it would interfere with the traversal.
The macros
.BR TAILQ_FOREACH_SAFE ()
and
.BR TAILQ_FOREACH_REVERSE_SAFE (),
which are present on the BSDs but are not present in glibc,
fix 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>
@ -398,3 +433,5 @@ main(void)
}
.EE
.SH SEE ALSO
.BR insque (3),
.BR queue (3)