summaryrefslogtreecommitdiff
path: root/source3/lib/talloc_stack.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/talloc_stack.c')
-rw-r--r--source3/lib/talloc_stack.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/source3/lib/talloc_stack.c b/source3/lib/talloc_stack.c
index d887b2d415..2722fb9676 100644
--- a/source3/lib/talloc_stack.c
+++ b/source3/lib/talloc_stack.c
@@ -64,9 +64,9 @@ static int talloc_pop(TALLOC_CTX *frame)
* not explicitly freed.
*/
-TALLOC_CTX *talloc_stackframe(void)
+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,7 +78,18 @@ TALLOC_CTX *talloc_stackframe(void)
talloc_stack_arraysize = talloc_stacksize + 1;
}
- top = talloc_new(talloc_stack);
+ if (talloc_stacksize == 0) {
+ parent = talloc_stack;
+ }
+ else {
+ parent = talloc_stack[talloc_stacksize-1];
+ }
+
+ if (poolsize) {
+ top = talloc_pool(parent, poolsize);
+ } else {
+ top = talloc_new(parent);
+ }
if (top == NULL) {
goto fail;
@@ -94,6 +105,16 @@ TALLOC_CTX *talloc_stackframe(void)
return NULL;
}
+TALLOC_CTX *talloc_stackframe(void)
+{
+ return talloc_stackframe_internal(0);
+}
+
+TALLOC_CTX *talloc_stackframe_pool(size_t poolsize)
+{
+ return talloc_stackframe_internal(poolsize);
+}
+
/*
* Get us the current top of the talloc stack.
*/