X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftal%2Ftest%2Frun-destructor.c;h=e3d0c0d88557319d3e87e7bade6073a12979d8cc;hp=873548889e91472013c3901b92bae8f01ae4e25c;hb=HEAD;hpb=d61a0d6c2c9d2b385075338665d64ae1d1bbe3dc diff --git a/ccan/tal/test/run-destructor.c b/ccan/tal/test/run-destructor.c index 87354888..e3d0c0d8 100644 --- a/ccan/tal/test/run-destructor.c +++ b/ccan/tal/test/run-destructor.c @@ -24,16 +24,22 @@ static void destroy_child(char *p) destroy_count++; } -static void destroy_inc(char *p) +static void destroy_inc(char *p UNNEEDED) { destroy_count++; } +static void remove_own_destructor(char *p) +{ + destroy_count++; + ok1(!tal_del_destructor(p, remove_own_destructor)); +} + int main(void) { char *child2; - plan_tests(18); + plan_tests(21); destroy_count = 0; parent = tal(NULL, char); @@ -63,6 +69,12 @@ int main(void) tal_free(parent); ok1(destroy_count == 4); + destroy_count = 0; + parent = tal(NULL, char); + ok1(tal_add_destructor(parent, remove_own_destructor)); + tal_free(parent); + ok1(destroy_count == 1); + tal_cleanup(); return exit_status(); }