6 * tlist - typesafe double linked list routines
8 * The list header contains routines for manipulating double linked lists;
9 * this extends it so you can create list head types which only accomodate
10 * a specific entry type.
16 * #include <ccan/tlist/tlist.h>
18 * // We could use TLIST_TYPE(children, struct child) to define this.
19 * struct tlist_children {
20 * struct list_head raw;
21 * TCON(struct child *canary);
25 * struct tlist_children children;
26 * unsigned int num_children;
31 * struct list_node list;
34 * int main(int argc, char *argv[])
41 * errx(1, "Usage: %s parent children...", argv[0]);
44 * tlist_init(&p.children);
45 * for (i = 2; i < argc; i++) {
46 * c = malloc(sizeof(*c));
48 * tlist_add(&p.children, c, list);
52 * printf("%s has %u children:", p.name, p.num_children);
53 * tlist_for_each(&p.children, c, list)
54 * printf("%s ", c->name);
60 * Author: Rusty Russell <rusty@rustcorp.com.au>
62 int main(int argc, char *argv[])
67 if (strcmp(argv[1], "depends") == 0) {
68 printf("ccan/list\n");
69 printf("ccan/tcon\n");