From: Andrew Bartlett Date: Sun, 27 Nov 2016 22:47:41 +0000 (+1300) Subject: talloc: Add tests for talloc_parent() after realloc() of the parent X-Git-Tag: ldb-1.1.29~20 X-Git-Url: http://git.samba.org/samba.git/?p=sfrench%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=5cb1882dc6ae044acd5e8fda2a19aca5fc9bc2fa talloc: Add tests for talloc_parent() after realloc() of the parent Signed-off-by: Andrew Bartlett Reviewed-by: Garming Sam --- diff --git a/lib/talloc/testsuite.c b/lib/talloc/testsuite.c index 7f98f4b4668..835d38be9ce 100644 --- a/lib/talloc/testsuite.c +++ b/lib/talloc/testsuite.c @@ -610,7 +610,7 @@ static bool test_realloc_child(void) void *root; struct el2 { const char *name; - } *el2; + } *el2, *el2_2, *el2_3; struct el1 { int count; struct el2 **list, **list2, **list3; @@ -634,13 +634,22 @@ static bool test_realloc_child(void) el1->list3[0]->name = talloc_strdup(el1->list3[0], "testing2"); el2 = talloc(el1->list, struct el2); - el2 = talloc(el1->list2, struct el2); - el2 = talloc(el1->list3, struct el2); - (void)el2; + CHECK_PARENT("el2", el2, el1->list); + el2_2 = talloc(el1->list2, struct el2); + CHECK_PARENT("el2", el2_2, el1->list2); + el2_3 = talloc(el1->list3, struct el2); + CHECK_PARENT("el2", el2_3, el1->list3); el1->list = talloc_realloc(el1, el1->list, struct el2 *, 100); + CHECK_PARENT("el1_after_realloc", el1->list, el1); el1->list2 = talloc_realloc(el1, el1->list2, struct el2 *, 200); + CHECK_PARENT("el1_after_realloc", el1->list2, el1); el1->list3 = talloc_realloc(el1, el1->list3, struct el2 *, 300); + CHECK_PARENT("el1_after_realloc", el1->list3, el1); + + CHECK_PARENT("el2", el2, el1->list); + CHECK_PARENT("el2", el2_2, el1->list2); + CHECK_PARENT("el2", el2_3, el1->list3); talloc_free(root);