X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftalloc%2Ftest%2Frun-test_autofree.c;fp=ccan%2Ftalloc%2Ftest%2Frun-test_autofree.c;h=0aa0c172c9fcbcf50d37b1d9954054a3d5a4e743;hp=0000000000000000000000000000000000000000;hb=87aba1fa2abc28ff06f82e30cde3fa3d991e8e18;hpb=f0002cb9e4f6f403a25ad50252c06694439900f0 diff --git a/ccan/talloc/test/run-test_autofree.c b/ccan/talloc/test/run-test_autofree.c new file mode 100644 index 00000000..0aa0c172 --- /dev/null +++ b/ccan/talloc/test/run-test_autofree.c @@ -0,0 +1,25 @@ +#include +#include +#include + +static int destroy_int(int *p) +{ + ok1(*p == 7); + _exit(0); +} + +int main(int argc, char *argv[]) +{ + int *p; + + /* If autofree context doesn't work, we won't run all tests! */ + plan_tests(1); + + p = talloc(talloc_autofree_context(), int); + *p = 7; + talloc_set_destructor(p, destroy_int); + + /* Note! We fail here, unless destructor called! */ + exit(1); +} +