From 1b8fbbd843ddeb5fc81c9303db9c590a436d499b Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 9 Jul 2018 12:10:32 -0700 Subject: progress --- ccan/tal/test/run-free.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ccan/tal/test/run-free.c (limited to 'ccan/tal/test/run-free.c') diff --git a/ccan/tal/test/run-free.c b/ccan/tal/test/run-free.c new file mode 100644 index 0000000..37d03cd --- /dev/null +++ b/ccan/tal/test/run-free.c @@ -0,0 +1,29 @@ +#include +#include +#include + +static void destroy_errno(char *p UNNEEDED) +{ + /* Errno restored for all the destructors. */ + ok1(errno == EINVAL); + errno = ENOENT; +} + +int main(void) +{ + char *p; + + plan_tests(5); + + p = tal(NULL, char); + ok1(tal_add_destructor(p, destroy_errno)); + ok1(tal_add_destructor(p, destroy_errno)); + + /* Errno save/restored across free. */ + errno = EINVAL; + tal_free(p); + ok1(errno == EINVAL); + + tal_cleanup(); + return exit_status(); +} -- cgit v1.2.3