diff options
author | Volker Lendecke <vl@samba.org> | 2008-01-08 22:12:35 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-01-08 22:18:08 +0100 |
commit | c7cb98d486ef8af1dc7111c2316fd73db9fef9f8 (patch) | |
tree | db653eeac70a439b67381dac32bcf6be12a356db /source/lib/talloc_stack.c | |
parent | 1a15778331393f9ece9aac9450828e799b20a058 (diff) | |
download | samba-c7cb98d486ef8af1dc7111c2316fd73db9fef9f8.tar.gz |
Only realloc the talloc stack if necessary
Diffstat (limited to 'source/lib/talloc_stack.c')
-rw-r--r-- | source/lib/talloc_stack.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/source/lib/talloc_stack.c b/source/lib/talloc_stack.c index cc7ce3a5187..d887b2d4154 100644 --- a/source/lib/talloc_stack.c +++ b/source/lib/talloc_stack.c @@ -39,6 +39,7 @@ #include "includes.h" static int talloc_stacksize; +static int talloc_stack_arraysize; static TALLOC_CTX **talloc_stack; static int talloc_pop(TALLOC_CTX *frame) @@ -67,21 +68,25 @@ TALLOC_CTX *talloc_stackframe(void) { TALLOC_CTX **tmp, *top; - if (!(tmp = TALLOC_REALLOC_ARRAY(NULL, talloc_stack, TALLOC_CTX *, - talloc_stacksize + 1))) { - goto fail; - } + if (talloc_stack_arraysize < talloc_stacksize + 1) { + tmp = TALLOC_REALLOC_ARRAY(NULL, talloc_stack, TALLOC_CTX *, + talloc_stacksize + 1); + if (tmp == NULL) { + goto fail; + } + talloc_stack = tmp; + talloc_stack_arraysize = talloc_stacksize + 1; + } - talloc_stack = tmp; + top = talloc_new(talloc_stack); - if (!(top = talloc_new(talloc_stack))) { + if (top == NULL) { goto fail; } talloc_set_destructor(top, talloc_pop); talloc_stack[talloc_stacksize++] = top; - return top; fail: |