summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-01-08 22:12:35 +0100
committerVolker Lendecke <vl@samba.org>2008-01-08 22:18:08 +0100
commit5274d8cda30f712f01a048862d0fdc532878eba5 (patch)
tree0ec1bb0de1bd7c4f88b299bbc0cd278bcdb6f149 /source3/lib
parent35c256226f7cbf1125ad7b6370eecdf09b3cfbc6 (diff)
downloadsamba-5274d8cda30f712f01a048862d0fdc532878eba5.tar.gz
samba-5274d8cda30f712f01a048862d0fdc532878eba5.tar.bz2
samba-5274d8cda30f712f01a048862d0fdc532878eba5.zip
Only realloc the talloc stack if necessary
(This used to be commit c7cb98d486ef8af1dc7111c2316fd73db9fef9f8)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/talloc_stack.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/source3/lib/talloc_stack.c b/source3/lib/talloc_stack.c
index cc7ce3a518..d887b2d415 100644
--- a/source3/lib/talloc_stack.c
+++ b/source3/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: