]> git.ozlabs.org Git - ccan/blobdiff - ccan/tal/test/run-free.c
tal: handle take() pointers more carefully.
[ccan] / ccan / tal / test / run-free.c
index 7b9a086e7c908bfe17b977d696ac0f6c85a0f7fe..37d03cd6ff4cbd0233950f0808129e939f9975e1 100644 (file)
@@ -2,8 +2,10 @@
 #include <ccan/tal/tal.c>
 #include <ccan/tap/tap.h>
 
-static void destroy_errno(char *p)
+static void destroy_errno(char *p UNNEEDED)
 {
+       /* Errno restored for all the destructors. */
+       ok1(errno == EINVAL);
        errno = ENOENT;
 }
 
@@ -11,15 +13,17 @@ int main(void)
 {
        char *p;
 
-       plan_tests(2);
+       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();
 }