circleq.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-23 16:57:35 +02:00 committed by Michael Kerrisk
parent 086acf39f1
commit ccb0db7f35
1 changed files with 38 additions and 0 deletions

View File

@ -49,6 +49,7 @@ CIRCLEQ_LOOP_PREV,
CIRCLEQ_NEXT,
CIRCLEQ_PREV,
CIRCLEQ_REMOVE
\- implementation of a double-linked circular queue
.SH SYNOPSIS
.nf
.B #include <sys/queue.h>
@ -96,6 +97,8 @@ CIRCLEQ_REMOVE
.PP
.BI "void CIRCLEQ_REMOVE(CIRCLEQ_HEAD *" head ", TYPE *" elm ", CIRCLEQ_ENTRY " NAME ");"
.SH DESCRIPTION
These macros define and operate on doubly-linked circular queues.
.PP
In the macro definitions,
.I TYPE
is the name of a user-defined structure,
@ -252,11 +255,44 @@ removes the element
.I elm
from the circular queue.
.SH RETURN VALUE
.BR CIRCLEQ_EMPTY ()
returns nonzero if the queue is empty,
and zero if the queue contains at least one entry.
.PP
.BR CIRCLEQ_FIRST (),
.BR CIRCLEQ_LAST (),
.BR CIRCLEQ_NEXT (),
and
.BR CIRCLEQ_PREV ()
return a pointer to the first, last, next or previous
.I CIRCLEQ_ENTRY
structure, respectively.
.PP
.BR CIRCLEQ_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
(CIRCLEQ macros first appeared in 4.4BSD).
.SH BUGS
The macros
.BR CIRCLEQ_FOREACH ()
and
.BR CIRCLEQ_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 CIRCLEQ_FOREACH_SAFE ()
and
.BR CIRCLEQ_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>
@ -314,3 +350,5 @@ main(void)
}
.EE
.SH SEE ALSO
.BR insque (3),
.BR queue (3)