1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

talloc_stack: handle more than one talloc_stackframe_pool()

The only reason we make one stackframe parent of the next is so we use
our parent's pool.  That doesn't make sense if we're a new pool, and
wouldn't work anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2012-07-18 04:55:31 +09:30
parent 4f331872bc
commit 311281c2c5

View File

@ -117,7 +117,7 @@ static int talloc_pop(TALLOC_CTX *frame)
static TALLOC_CTX *talloc_stackframe_internal(size_t poolsize) static TALLOC_CTX *talloc_stackframe_internal(size_t poolsize)
{ {
TALLOC_CTX **tmp, *top, *parent; TALLOC_CTX **tmp, *top;
struct talloc_stackframe *ts = struct talloc_stackframe *ts =
(struct talloc_stackframe *)SMB_THREAD_GET_TLS(global_ts); (struct talloc_stackframe *)SMB_THREAD_GET_TLS(global_ts);
@ -135,15 +135,16 @@ static TALLOC_CTX *talloc_stackframe_internal(size_t poolsize)
ts->talloc_stack_arraysize = ts->talloc_stacksize + 1; ts->talloc_stack_arraysize = ts->talloc_stacksize + 1;
} }
if (ts->talloc_stacksize == 0) {
parent = ts->talloc_stack;
} else {
parent = ts->talloc_stack[ts->talloc_stacksize-1];
}
if (poolsize) { if (poolsize) {
top = talloc_pool(parent, poolsize); top = talloc_pool(ts->talloc_stack, poolsize);
} else { } else {
TALLOC_CTX *parent;
/* We chain parentage, so if one is a pool we draw from it. */
if (ts->talloc_stacksize == 0) {
parent = ts->talloc_stack;
} else {
parent = ts->talloc_stack[ts->talloc_stacksize-1];
}
top = talloc_new(parent); top = talloc_new(parent);
} }