View | Details | Raw Unified | Return to bug 192267
Collapse All | Expand All

(-)b/share/man/man3/queue.3 (-16 / +20 lines)
Lines 28-34 Link Here
28
.\"	@(#)queue.3	8.2 (Berkeley) 1/24/94
28
.\"	@(#)queue.3	8.2 (Berkeley) 1/24/94
29
.\" $FreeBSD$
29
.\" $FreeBSD$
30
.\"
30
.\"
31
.Dd September 8, 2016
31
.Dd October 11, 2021
32
.Dt QUEUE 3
32
.Dt QUEUE 3
33
.Os
33
.Os
34
.Sh NAME
34
.Sh NAME
Lines 332-341 Each head entry requires two pointers rather than one. Link Here
332
Code size is about 15% greater and operations run about 20% slower
332
Code size is about 15% greater and operations run about 20% slower
333
than singly-linked lists.
333
than singly-linked lists.
334
.El
334
.El
335
.Pp
335
.Ss MACRO DEFINITIONS
336
In the macro definitions,
336
.Bl -tag -width "CLASSTYPE"
337
.Fa TYPE
337
.It Fa TYPE
338
is the name of a user defined structure.
338
The name of a user defined structure.
339
The structure must contain a field called
339
The structure must contain a field called
340
.Fa NAME
340
.Fa NAME
341
which is of type
341
which is of type
Lines 344-352 which is of type Link Here
344
.Li LIST_ENTRY ,
344
.Li LIST_ENTRY ,
345
or
345
or
346
.Li TAILQ_ENTRY .
346
.Li TAILQ_ENTRY .
347
In the macro definitions,
347
.It Fa CLASSTYPE
348
.Fa CLASSTYPE
348
The name of a user defined class.
349
is the name of a user defined class.
350
The class must contain a field called
349
The class must contain a field called
351
.Fa NAME
350
.Fa NAME
352
which is of type
351
which is of type
Lines 355-363 which is of type Link Here
355
.Li LIST_CLASS_ENTRY ,
354
.Li LIST_CLASS_ENTRY ,
356
or
355
or
357
.Li TAILQ_CLASS_ENTRY .
356
.Li TAILQ_CLASS_ENTRY .
358
The argument
357
.It Fa HEADNAME
359
.Fa HEADNAME
358
The name of a user defined structure that must be declared
360
is the name of a user defined structure that must be declared
361
using the macros
359
using the macros
362
.Li SLIST_HEAD ,
360
.Li SLIST_HEAD ,
363
.Li SLIST_CLASS_HEAD ,
361
.Li SLIST_CLASS_HEAD ,
Lines 368-373 using the macros Link Here
368
.Li TAILQ_HEAD ,
366
.Li TAILQ_HEAD ,
369
or
367
or
370
.Li TAILQ_CLASS_HEAD .
368
.Li TAILQ_CLASS_HEAD .
369
.Pp
370
If
371
.Fa HEADNAME
372
is omitted, the resulting data structure will be anonymous.
373
.El
374
.Pp
371
See the examples below for further explanation of how these
375
See the examples below for further explanation of how these
372
macros are used.
376
macros are used.
373
.Sh SINGLY-LINKED LISTS
377
.Sh SINGLY-LINKED LISTS
Lines 568-574 free(n3); Link Here
568
SLIST_FOREACH(np, &head, entries)
572
SLIST_FOREACH(np, &head, entries)
569
	np-> ...
573
	np-> ...
570
					/* Safe forward traversal. */
574
					/* Safe forward traversal. */
571
SLIST_FOREACH_SAFE(np, &head, entries, np_temp) {
575
SLIST_FOREACH_SAFE(np, &head, entries, tvar) {
572
	np->do_stuff();
576
	np->do_stuff();
573
	...
577
	...
574
	SLIST_REMOVE(&head, np, entry, entries);
578
	SLIST_REMOVE(&head, np, entry, entries);
Lines 790-796 free(n3); Link Here
790
STAILQ_FOREACH(np, &head, entries)
794
STAILQ_FOREACH(np, &head, entries)
791
	np-> ...
795
	np-> ...
792
					/* Safe forward traversal. */
796
					/* Safe forward traversal. */
793
STAILQ_FOREACH_SAFE(np, &head, entries, np_temp) {
797
STAILQ_FOREACH_SAFE(np, &head, entries, tvar) {
794
	np->do_stuff();
798
	np->do_stuff();
795
	...
799
	...
796
	STAILQ_REMOVE(&head, np, entry, entries);
800
	STAILQ_REMOVE(&head, np, entry, entries);
Lines 980-986 struct entry { Link Here
980
	...
984
	...
981
	LIST_ENTRY(entry) entries;	/* List. */
985
	LIST_ENTRY(entry) entries;	/* List. */
982
	...
986
	...
983
} *n1, *n2, *n3, *np, *np_temp;
987
} *n1, *n2, *n3, *np, *tvar;
984
988
985
LIST_INIT(&head);			/* Initialize the list. */
989
LIST_INIT(&head);			/* Initialize the list. */
986
990
Lines 1000-1006 LIST_FOREACH(np, &head, entries) Link Here
1000
	np-> ...
1004
	np-> ...
1001
1005
1002
					/* Safe forward traversal. */
1006
					/* Safe forward traversal. */
1003
LIST_FOREACH_SAFE(np, &head, entries, np_temp) {
1007
LIST_FOREACH_SAFE(np, &head, entries, tvar) {
1004
	np->do_stuff();
1008
	np->do_stuff();
1005
	...
1009
	...
1006
	LIST_REMOVE(np, entries);
1010
	LIST_REMOVE(np, entries);
Lines 1260-1266 free(n2); Link Here
1260
TAILQ_FOREACH(np, &head, entries)
1264
TAILQ_FOREACH(np, &head, entries)
1261
	np-> ...
1265
	np-> ...
1262
					/* Safe forward traversal. */
1266
					/* Safe forward traversal. */
1263
TAILQ_FOREACH_SAFE(np, &head, entries, np_temp) {
1267
TAILQ_FOREACH_SAFE(np, &head, entries, tvar) {
1264
	np->do_stuff();
1268
	np->do_stuff();
1265
	...
1269
	...
1266
	TAILQ_REMOVE(&head, np, entries);
1270
	TAILQ_REMOVE(&head, np, entries);

Return to bug 192267