diff options
author | Volker Lendecke <vl@samba.org> | 2008-01-06 17:25:20 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-01-07 21:18:00 +0100 |
commit | 8d261ee580f7d589920eb405a68aec04e6cc8e7a (patch) | |
tree | 262e45edb403ad4e4eb21c494f1fd73080c1c76a | |
parent | c8abd25d94fba0df62136c33837ddfcdaa459a66 (diff) | |
download | samba-8d261ee580f7d589920eb405a68aec04e6cc8e7a.tar.gz samba-8d261ee580f7d589920eb405a68aec04e6cc8e7a.tar.xz samba-8d261ee580f7d589920eb405a68aec04e6cc8e7a.zip |
talloc_stackframe only needs 1 talloc
(This used to be commit c0c2084d40b79e949dab7c68626aa665b9ea1a8e)
-rw-r--r-- | source3/lib/talloc_stack.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/source3/lib/talloc_stack.c b/source3/lib/talloc_stack.c index e6e4ed321a5..cc7ce3a5187 100644 --- a/source3/lib/talloc_stack.c +++ b/source3/lib/talloc_stack.c @@ -41,16 +41,18 @@ static int talloc_stacksize; static TALLOC_CTX **talloc_stack; -static int talloc_pop(int *ptr) +static int talloc_pop(TALLOC_CTX *frame) { - int tos = *ptr; int i; - for (i=talloc_stacksize-1; i>=tos; i--) { + for (i=talloc_stacksize-1; i>0; i--) { + if (frame == talloc_stack[i]) { + break; + } talloc_free(talloc_stack[i]); } - talloc_stacksize = tos; + talloc_stacksize = i; return 0; } @@ -64,7 +66,6 @@ static int talloc_pop(int *ptr) TALLOC_CTX *talloc_stackframe(void) { TALLOC_CTX **tmp, *top; - int *cleanup; if (!(tmp = TALLOC_REALLOC_ARRAY(NULL, talloc_stack, TALLOC_CTX *, talloc_stacksize + 1))) { @@ -77,12 +78,7 @@ TALLOC_CTX *talloc_stackframe(void) goto fail; } - if (!(cleanup = talloc(top, int))) { - goto fail; - } - - *cleanup = talloc_stacksize; - talloc_set_destructor(cleanup, talloc_pop); + talloc_set_destructor(top, talloc_pop); talloc_stack[talloc_stacksize++] = top; |