X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftal%2Ftest%2Frun-free.c;fp=ccan%2Ftal%2Ftest%2Frun-free.c;h=7b9a086e7c908bfe17b977d696ac0f6c85a0f7fe;hb=34c2962d00c4ec24f248bddfd42f2e79cc6b61ef;hp=0000000000000000000000000000000000000000;hpb=78ba5de2dc4c74f772b9e40cd673476dac6d7a1a;p=ccan diff --git a/ccan/tal/test/run-free.c b/ccan/tal/test/run-free.c new file mode 100644 index 00000000..7b9a086e --- /dev/null +++ b/ccan/tal/test/run-free.c @@ -0,0 +1,25 @@ +#include +#include +#include + +static void destroy_errno(char *p) +{ + errno = ENOENT; +} + +int main(void) +{ + char *p; + + plan_tests(2); + + p = tal(NULL, char); + ok1(tal_add_destructor(p, destroy_errno)); + + /* Errno save/restored across free. */ + errno = EINVAL; + tal_free(p); + ok1(errno == EINVAL); + + return exit_status(); +}