summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2016-11-28 11:47:41 +1300
committerAndrew Bartlett <abartlet@samba.org>2016-12-01 05:54:22 +0100
commit5cb1882dc6ae044acd5e8fda2a19aca5fc9bc2fa (patch)
tree058fafe5ad2a13099b4c2dfb2ebf2c5935eb182a /lib
parent48c897f126b68c1bc5b5b05e203e65fa1dc89390 (diff)
downloadsamba-5cb1882dc6ae044acd5e8fda2a19aca5fc9bc2fa.tar.gz
talloc: Add tests for talloc_parent() after realloc() of the parent
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'lib')
-rw-r--r--lib/talloc/testsuite.c17
1 files changed, 13 insertions, 4 deletions
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);