1 #include <ccan/foreach/foreach.h>
2 #include <ccan/tap/tap.h>
6 #include <ccan/foreach/foreach.c>
9 static void *allocs[1000];
10 static unsigned int num_allocs;
12 static void iterate(unsigned int depth, bool done_global)
15 const char *expectp[] = { "hello", "there" };
24 foreach_int(global_i, 0, 1) {
25 ok1(global_i == expecti);
28 iterate(depth + 1, true);
33 i = allocs[num_allocs++] = malloc(sizeof(*i));
35 foreach_int(*i, 0, 1) {
39 iterate(depth + 1, done_global);
43 p = allocs[num_allocs++] = malloc(sizeof(*p));
45 foreach_ptr(*p, "hello", "there") {
46 ok1(strcmp(expectp[expecti], *p) == 0);
49 iterate(depth + 1, done_global);
55 foreach_int(stack_i, 0, 1) {
56 ok1(stack_i == expecti);
59 iterate(depth + 1, done_global);
71 ok1(num_allocs < 1000);
72 for (i = 0; i < num_allocs; i++)