tal: handle take() pointers more carefully.
[ccan] / ccan / tal / test / run-take.c
index d93304e206bdf4207cb33bc7bd5eaf12333eb982..4a7f0c7495374fa72696dce45e6111ca024fec09 100644 (file)
@@ -6,7 +6,7 @@ int main(void)
 {
        char *parent, *c;
 
-       plan_tests(21);
+       plan_tests(22);
 
        /* We can take NULL. */
        ok1(take(NULL) == NULL);
@@ -44,6 +44,12 @@ int main(void)
        tal_free(c);
        ok1(tal_first(parent) == NULL);
 
+       /* tal_resize should return a taken pointer. */
+       c = take(tal_arr(parent, char, 5));
+       tal_resize(&c, 100);
+       ok1(taken(c));
+       tal_free(c);
+
        tal_free(parent);
        ok1(!taken_any());