compiler: RETURNS_NONNULL macro
[ccan] / ccan / tal / test / run-free.c
1 #include <ccan/tal/tal.h>
2 #include <ccan/tal/tal.c>
3 #include <ccan/tap/tap.h>
4
5 static void destroy_errno(char *p UNNEEDED)
6 {
7         /* Errno restored for all the destructors. */
8         ok1(errno == EINVAL);
9         errno = ENOENT;
10 }
11
12 int main(void)
13 {
14         char *p;
15
16         plan_tests(5);
17
18         p = tal(NULL, char);
19         ok1(tal_add_destructor(p, destroy_errno));
20         ok1(tal_add_destructor(p, destroy_errno));
21
22         /* Errno save/restored across free. */
23         errno = EINVAL;
24         tal_free(p);
25         ok1(errno == EINVAL);
26
27         tal_cleanup();
28         return exit_status();
29 }