]> git.ozlabs.org Git - ccan/blob - ccan/tal/talloc/test/run-free.c
Merge branch 'rfc822'
[ccan] / ccan / tal / talloc / test / run-free.c
1 #include <ccan/tal/talloc/talloc.h>
2 #include <ccan/tal/talloc/talloc.c>
3 #include <ccan/tap/tap.h>
4 #include <errno.h>
5
6 static void destroy_errno(char *p)
7 {
8         errno = ENOENT;
9 }
10
11 int main(void)
12 {
13         char *p;
14
15         plan_tests(2);
16
17         p = tal(NULL, char);
18         ok1(tal_add_destructor(p, destroy_errno));
19
20         /* Errno save/restored across free. */
21         errno = EINVAL;
22         tal_free(p);
23         ok1(errno == EINVAL);
24
25         return exit_status();
26 }