summaryrefslogtreecommitdiff
path: root/lib/talloc/talloc.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-09-20 13:14:40 -0700
committerAndrew Tridgell <tridge@samba.org>2009-09-20 13:14:40 -0700
commit3c5d7639624f6a82e75328e30dfd89e8ae728c55 (patch)
tree7029dd1531ceb1864d0b45a8c243a284f10e118b /lib/talloc/talloc.c
parent05653fce788d239433a93e68b71c1d280f02161a (diff)
downloadsamba-3c5d7639624f6a82e75328e30dfd89e8ae728c55.tar.gz
samba-3c5d7639624f6a82e75328e30dfd89e8ae728c55.tar.bz2
samba-3c5d7639624f6a82e75328e30dfd89e8ae728c55.zip
talloc: fixed talloc_disable_null_tracking()
When we disable null tracking, we need to move any existing objects that are under the null_context to be parented by the true NULL context. We also need a new talloc_enable_null_tracking_no_autofree() function, as the talloc testsuite cannot cope with the moving of the autofree context under the null_context as it wants to check exact counts of objects under the null_context, and smbtorture has a large number of objects in the autofree_context from .init functions
Diffstat (limited to 'lib/talloc/talloc.c')
-rw-r--r--lib/talloc/talloc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index f103a9b941..7beda4b0f5 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -1477,10 +1477,37 @@ void talloc_enable_null_tracking(void)
}
/*
+ enable tracking of the NULL context, not moving the autofree context
+ into the NULL context. This is needed for the talloc testsuite
+*/
+void talloc_enable_null_tracking_no_autofree(void)
+{
+ if (null_context == NULL) {
+ null_context = _talloc_named_const(NULL, 0, "null_context");
+ }
+}
+
+/*
disable tracking of the NULL context
*/
void talloc_disable_null_tracking(void)
{
+ if (null_context != NULL) {
+ /* we have to move any children onto the real NULL
+ context */
+ struct talloc_chunk *tc, *tc2;
+ tc = talloc_chunk_from_ptr(null_context);
+ for (tc2 = tc->child; tc2; tc2=tc2->next) {
+ if (tc2->parent == tc) tc2->parent = NULL;
+ if (tc2->prev == tc) tc2->prev = NULL;
+ }
+ for (tc2 = tc->next; tc2; tc2=tc2->next) {
+ if (tc2->parent == tc) tc2->parent = NULL;
+ if (tc2->prev == tc) tc2->prev = NULL;
+ }
+ tc->child = NULL;
+ tc->next = NULL;
+ }
talloc_free(null_context);
null_context = NULL;
}