7 LIST_HEAD(listhead
, entry
) head
;
8 struct listhead
*headp
;
11 LIST_ENTRY(entry
) entries
;
15 void diep(const char *s
);
19 const char *str
[] = { "this", "is", "a", "linked", "list" };
26 /* Populate list with str[] items */
27 for (i
= 0; i
< sizeof str
/ sizeof *str
; i
++) {
28 n
= malloc(sizeof(struct entry
));
34 LIST_INSERT_HEAD(&head
, n
, entries
);
36 LIST_INSERT_AFTER(np
, n
, entries
);
41 LIST_FOREACH(np
, &head
, entries
)
42 printf("%s\n", np
->str
);
44 /* Delete all elements */
45 while (LIST_FIRST(&head
) != NULL
)
46 LIST_REMOVE(LIST_FIRST(&head
), entries
);
51 void diep(const char *s
)