summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-05-17 08:20:13 +0200
committerKarolin Seeger <kseeger@samba.org>2011-06-07 20:00:00 +0200
commitb572ce13426edc526a017e1f95260f874d7127a5 (patch)
tree7eb9c839947ba169311e0230d42784e2b136e381 /lib
parentae69c18ffb2fbf2c860ad97ed2a1caa15af7f29a (diff)
downloadsamba-b572ce13426edc526a017e1f95260f874d7127a5.tar.gz
talloc: add memset() calls to test_pool()
This way we the pool based valgrind code. metze (cherry picked from commit 16cc52cf70a9918843f9761baf483338c80bf1d0) (cherry picked from commit ade2fe7e8fc299e01ba13a08c95598eefa5b99b5)
Diffstat (limited to 'lib')
-rw-r--r--lib/talloc/testsuite.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/talloc/testsuite.c b/lib/talloc/testsuite.c
index ba583ab84ec..14085454f4e 100644
--- a/lib/talloc/testsuite.c
+++ b/lib/talloc/testsuite.c
@@ -1128,23 +1128,31 @@ static bool test_pool(void)
pool = talloc_pool(NULL, 1024);
p1 = talloc_size(pool, 80);
+ memset(p1, 0x11, talloc_get_size(p1));
p2 = talloc_size(pool, 20);
+ memset(p2, 0x11, talloc_get_size(p2));
p3 = talloc_size(p1, 50);
+ memset(p3, 0x11, talloc_get_size(p3));
p4 = talloc_size(p3, 1000);
+ memset(p4, 0x11, talloc_get_size(p4));
#if 1 /* this relies on ALWAYS_REALLOC == 0 in talloc.c */
p2_2 = talloc_realloc_size(pool, p2, 20+1);
torture_assert("pool realloc 20+1", p2_2 == p2, "failed: pointer changed");
+ memset(p2, 0x11, talloc_get_size(p2));
p2_2 = talloc_realloc_size(pool, p2, 20-1);
torture_assert("pool realloc 20-1", p2_2 == p2, "failed: pointer changed");
+ memset(p2, 0x11, talloc_get_size(p2));
p2_2 = talloc_realloc_size(pool, p2, 20-1);
torture_assert("pool realloc 20-1", p2_2 == p2, "failed: pointer changed");
+ memset(p2, 0x11, talloc_get_size(p2));
talloc_free(p3);
/* this should reclaim the memory of p4 and p3 */
p2_2 = talloc_realloc_size(pool, p2, 400);
torture_assert("pool realloc 400", p2_2 == p2, "failed: pointer changed");
+ memset(p2, 0x11, talloc_get_size(p2));
talloc_free(p1);
@@ -1152,37 +1160,46 @@ static bool test_pool(void)
p2_2 = talloc_realloc_size(pool, p2, 800);
torture_assert("pool realloc 800", p2_2 == p1, "failed: pointer not changed");
p2 = p2_2;
+ memset(p2, 0x11, talloc_get_size(p2));
/* this should do a malloc */
p2_2 = talloc_realloc_size(pool, p2, 1800);
torture_assert("pool realloc 1800", p2_2 != p2, "failed: pointer not changed");
p2 = p2_2;
+ memset(p2, 0x11, talloc_get_size(p2));
/* this should reclaim the memory from the pool */
p3 = talloc_size(pool, 80);
torture_assert("pool alloc 80", p3 == p1, "failed: pointer changed");
+ memset(p3, 0x11, talloc_get_size(p3));
talloc_free(p2);
talloc_free(p3);
p1 = talloc_size(pool, 80);
+ memset(p1, 0x11, talloc_get_size(p1));
p2 = talloc_size(pool, 20);
+ memset(p2, 0x11, talloc_get_size(p2));
talloc_free(p1);
p2_2 = talloc_realloc_size(pool, p2, 20-1);
torture_assert("pool realloc 20-1", p2_2 == p2, "failed: pointer changed");
+ memset(p2, 0x11, talloc_get_size(p2));
p2_2 = talloc_realloc_size(pool, p2, 20-1);
torture_assert("pool realloc 20-1", p2_2 == p2, "failed: pointer changed");
+ memset(p2, 0x11, talloc_get_size(p2));
/* this should do a malloc */
p2_2 = talloc_realloc_size(pool, p2, 1800);
torture_assert("pool realloc 1800", p2_2 != p2, "failed: pointer not changed");
p2 = p2_2;
+ memset(p2, 0x11, talloc_get_size(p2));
/* this should reclaim the memory from the pool */
p3 = talloc_size(pool, 800);
torture_assert("pool alloc 800", p3 == p1, "failed: pointer changed");
+ memset(p3, 0x11, talloc_get_size(p3));
#endif /* this relies on ALWAYS_REALLOC == 0 in talloc.c */