Tracing for tdb operations.
[ccan] / ccan / list / test / compile_ok-constant.c
1 #include "list/list.h"
2 #include "tap/tap.h"
3 #include "list/list.c"
4 #include <stdbool.h>
5 #include <stdio.h>
6
7 struct child {
8         const char *name;
9         struct list_node list;
10 };
11
12 static bool children(const struct list_head *list)
13 {
14         return !list_empty(list);
15 }
16
17 static const struct child *first_child(const struct list_head *list)
18 {
19         return list_top(list, struct child, list);
20 }
21
22 static const struct child *last_child(const struct list_head *list)
23 {
24         return list_tail(list, struct child, list);
25 }
26
27 static void check_children(const struct list_head *list)
28 {
29         list_check(list, "bad child list");
30 }
31
32 static void print_children(const struct list_head *list)
33 {
34         const struct child *c;
35         list_for_each(list, c, list)
36                 printf("%s\n", c->name);
37 }
38
39 int main(void)
40 {
41         LIST_HEAD(h);
42
43         children(&h);
44         first_child(&h);
45         last_child(&h);
46         check_children(&h);
47         print_children(&h);
48         return 0;
49 }