diff --git a/man3/circleq.3 b/man3/circleq.3 index f24df2e15..33215be77 100644 --- a/man3/circleq.3 +++ b/man3/circleq.3 @@ -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 @@ -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 @@ -314,3 +350,5 @@ main(void) } .EE .SH SEE ALSO +.BR insque (3), +.BR queue (3)