mirror of https://github.com/mkerrisk/man-pages
list.3: Add details
list.3: NAME: Add description list.3: DESCRIPTION: Add short description list.3: SEE ALSO: Add insque(3) and queue(3) list.3: BUGS: Note LIST_FOREACH() limitations list.3: RETURN VALUE: Add details about the return value of those macros that "return" a value 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:
parent
87241f17f6
commit
ce6606e121
33
man3/list.3
33
man3/list.3
|
@ -48,6 +48,7 @@ LIST_NEXT,
|
|||
LIST_PREV,
|
||||
LIST_REMOVE
|
||||
.\"LIST_SWAP
|
||||
\- implementation of a doubly-linked list
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <sys/queue.h>
|
||||
|
@ -87,6 +88,8 @@ LIST_REMOVE
|
|||
.\".BI "void LIST_SWAP(LIST_HEAD *" head1 ", LIST_HEAD *" head2 ", TYPE, LIST_ENTRY " NAME ");"
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
These macros define and operate on doubly-linked lists.
|
||||
.PP
|
||||
In the macro definitions,
|
||||
.I TYPE
|
||||
is the name of a user defined structure,
|
||||
|
@ -253,11 +256,39 @@ from the list.
|
|||
.\" and
|
||||
.\" .IR head2 .
|
||||
.SH RETURN VALUE
|
||||
.BR LIST_EMPTY ()
|
||||
returns non-zero if the list is empty,
|
||||
and zero if the list contains at least one entry.
|
||||
.PP
|
||||
.BR LIST_FIRST (),
|
||||
and
|
||||
.BR LIST_NEXT ()
|
||||
return a pointer to the first or next
|
||||
.I LIST_ENTRY
|
||||
structre, respectively.
|
||||
.PP
|
||||
.BR LIST_HEAD_INITIALIZER ()
|
||||
returns an initializer that can be assigned to the list
|
||||
.IR head .
|
||||
.SH CONFORMING TO
|
||||
Not in POSIX.1, POSIX.1-2001 or POSIX.1-2008.
|
||||
Present on the BSDs
|
||||
(LIST macros first appeared in 4.4BSD).
|
||||
.SH BUGS
|
||||
The macro
|
||||
.BR LIST_FOREACH ()
|
||||
doesn't allow
|
||||
.I var
|
||||
to be removed or freed within the loop,
|
||||
as it would interfere with the traversal.
|
||||
The macro
|
||||
.BR LIST_FOREACH_SAFE (),
|
||||
which is not present in glibc,
|
||||
solves this bug by
|
||||
allowing to both remove
|
||||
.I var
|
||||
as well as free it from within the loop safely
|
||||
without interfering with the traversal.
|
||||
.SH EXAMPLES
|
||||
.EX
|
||||
#include <stddef.h>
|
||||
|
@ -312,3 +343,5 @@ main(void)
|
|||
}
|
||||
.EE
|
||||
.SH SEE ALSO
|
||||
.BR insque (3),
|
||||
.BR queue (3)
|
||||
|
|
Loading…
Reference in New Issue