6 * tlist2 - typesafe double linked list routines, alternative form
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.
12 * Compared to 'tlist', this:
14 * - does not allow (or require) declaring an extra struct (uses anonymous
16 * - encodes the member offset into the type (and as a result doesn't need the
17 * member name, but requires the source list)
19 * Based on tlist by: Rusty Russell <rusty@rustcorp.com.au>
25 * #include <ccan/tlist2/tlist2.h>
29 * struct list_node list;
34 * TLIST2(struct child, list) children;
35 * unsigned int num_children;
38 * int main(int argc, char *argv[])
45 * errx(1, "Usage: %s parent children...", argv[0]);
48 * tlist2_init(&p.children);
49 * for (i = 2; i < argc; i++) {
50 * c = malloc(sizeof(*c));
52 * tlist2_add(&p.children, c);
56 * printf("%s has %u children:", p.name, p.num_children);
57 * tlist2_for_each(&p.children, c)
58 * printf("%s ", c->name);
64 * Author: Cody P Schafer <dev@codyps.com>
66 int main(int argc, char *argv[])
71 if (strcmp(argv[1], "depends") == 0) {
72 printf("ccan/list\n");
73 printf("ccan/tcon\n");