diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2012-07-18 04:55:31 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-07-18 04:55:31 +0930 |
commit | 311281c2c550b71ec4d8b2fc7329a1dfe5af82b0 (patch) | |
tree | 6b8de062bb35730e4921593bb5171807d15fde8c /lib | |
parent | 4f331872bc783445c709e5fe4846b8687e274953 (diff) | |
download | samba-311281c2c550b71ec4d8b2fc7329a1dfe5af82b0.tar.gz samba-311281c2c550b71ec4d8b2fc7329a1dfe5af82b0.tar.bz2 samba-311281c2c550b71ec4d8b2fc7329a1dfe5af82b0.zip |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/talloc_stack.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/util/talloc_stack.c b/lib/util/talloc_stack.c index 16e9d745d3..b837843c84 100644 --- a/lib/util/talloc_stack.c +++ b/lib/util/talloc_stack.c @@ -117,7 +117,7 @@ static int talloc_pop(TALLOC_CTX *frame) 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 *)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; } - if (ts->talloc_stacksize == 0) { - parent = ts->talloc_stack; - } else { - parent = ts->talloc_stack[ts->talloc_stacksize-1]; - } - if (poolsize) { - top = talloc_pool(parent, poolsize); + top = talloc_pool(ts->talloc_stack, poolsize); } 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); } |