From f6274959ba381b6b5d025cb0cee78665107a72a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 Jan 2007 11:16:11 +0000 Subject: r20647: add cluster code (This used to be commit 5870830b99a8d76bda1ff5af3fcf8dda9aba50ec) --- source4/lib/talloc/testsuite.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source4/lib/talloc') diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c index 88ed638252..dbfe3e4417 100644 --- a/source4/lib/talloc/testsuite.c +++ b/source4/lib/talloc/testsuite.c @@ -1028,6 +1028,39 @@ static bool test_autofree(void) return true; } +static bool test_incref(void) +{ + void *top = talloc_new(NULL); + char *a = talloc_strdup(top, "/"); + char *b = talloc_strdup(a,"/b"); + char *c = talloc_strdup(b,"/b/a"); + + // Make a have some more children + talloc_strdup(a,"/c"); + talloc_strdup(a,"/d"); + talloc_strdup(a,"/e"); + + // Now b has some more other children. + talloc_strdup(b,"/b/b"); + + //Now we incref c presumably because we want to keep it valid: + talloc_increase_ref_count(c); + + // I am freeing a here, but I expect c to still be valid because I have + // increased reference for it just above. + talloc_free(a); + + talloc_report_full(NULL, stdout); + + // This is where talloc aborts, valgrind indicates a double free + talloc_free(c); + + CHECK_BLOCKS("top", top, 1); + + return true; +}; + + struct torture_context; bool torture_local_talloc(struct torture_context *tctx) { @@ -1044,6 +1077,7 @@ bool torture_local_talloc(struct torture_context *tctx) ret &= test_ref4(); ret &= test_unlink1(); ret &= test_misc(); + ret &= test_incref(); ret &= test_realloc(); ret &= test_realloc_child(); ret &= test_steal(); -- cgit