From 7579e08599dd2139617da5639144700774233c08 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 10 Jan 2008 09:53:51 +0100 Subject: Form a proper hierarchy in talloc_stack This way talloc_stackframe() can benefit from a pool put on the stack further up. No need to remove talloc_stackframe(). (This used to be commit be6fe381168321ae62e079cd977cbef675c532d4) --- source3/lib/talloc_stack.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/talloc_stack.c b/source3/lib/talloc_stack.c index 08ef2281ea..2722fb9676 100644 --- a/source3/lib/talloc_stack.c +++ b/source3/lib/talloc_stack.c @@ -66,7 +66,7 @@ static int talloc_pop(TALLOC_CTX *frame) static TALLOC_CTX *talloc_stackframe_internal(size_t poolsize) { - TALLOC_CTX **tmp, *top; + TALLOC_CTX **tmp, *top, *parent; if (talloc_stack_arraysize < talloc_stacksize + 1) { tmp = TALLOC_REALLOC_ARRAY(NULL, talloc_stack, TALLOC_CTX *, @@ -78,10 +78,17 @@ static TALLOC_CTX *talloc_stackframe_internal(size_t poolsize) talloc_stack_arraysize = talloc_stacksize + 1; } + if (talloc_stacksize == 0) { + parent = talloc_stack; + } + else { + parent = talloc_stack[talloc_stacksize-1]; + } + if (poolsize) { - top = talloc_pool(talloc_stack, poolsize); + top = talloc_pool(parent, poolsize); } else { - top = talloc_new(talloc_stack); + top = talloc_new(parent); } if (top == NULL) { -- cgit