summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-07-18 04:56:31 +0930
committerRusty Russell <rusty@rustcorp.com.au>2012-07-18 04:56:31 +0930
commitf9b51ff33e10aa126de848072e98b0bf36a7dbc7 (patch)
tree3cfd9983131628b0e4cb3b2c060cdedf6f2d0a4b
parent311281c2c550b71ec4d8b2fc7329a1dfe5af82b0 (diff)
downloadsamba-f9b51ff33e10aa126de848072e98b0bf36a7dbc7.tar.gz
samba-f9b51ff33e10aa126de848072e98b0bf36a7dbc7.tar.bz2
samba-f9b51ff33e10aa126de848072e98b0bf36a7dbc7.zip
talloc_stack: always include the location when creating a talloc_stackframe().
Much better for debugging. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--lib/util/talloc_stack.c13
-rw-r--r--lib/util/talloc_stack.h6
2 files changed, 11 insertions, 8 deletions
diff --git a/lib/util/talloc_stack.c b/lib/util/talloc_stack.c
index b837843c84..304ea17d8c 100644
--- a/lib/util/talloc_stack.c
+++ b/lib/util/talloc_stack.c
@@ -115,7 +115,8 @@ static int talloc_pop(TALLOC_CTX *frame)
* not explicitly freed.
*/
-static TALLOC_CTX *talloc_stackframe_internal(size_t poolsize)
+static TALLOC_CTX *talloc_stackframe_internal(const char *location,
+ size_t poolsize)
{
TALLOC_CTX **tmp, *top;
struct talloc_stackframe *ts =
@@ -151,7 +152,7 @@ static TALLOC_CTX *talloc_stackframe_internal(size_t poolsize)
if (top == NULL) {
goto fail;
}
-
+ talloc_set_name_const(top, location);
talloc_set_destructor(top, talloc_pop);
ts->talloc_stack[ts->talloc_stacksize++] = top;
@@ -162,14 +163,14 @@ static TALLOC_CTX *talloc_stackframe_internal(size_t poolsize)
return NULL;
}
-TALLOC_CTX *talloc_stackframe(void)
+TALLOC_CTX *_talloc_stackframe(const char *location)
{
- return talloc_stackframe_internal(0);
+ return talloc_stackframe_internal(location, 0);
}
-TALLOC_CTX *talloc_stackframe_pool(size_t poolsize)
+TALLOC_CTX *_talloc_stackframe_pool(const char *location, size_t poolsize)
{
- return talloc_stackframe_internal(poolsize);
+ return talloc_stackframe_internal(location, poolsize);
}
/*
diff --git a/lib/util/talloc_stack.h b/lib/util/talloc_stack.h
index ec0c1c6f37..8e1644624b 100644
--- a/lib/util/talloc_stack.h
+++ b/lib/util/talloc_stack.h
@@ -44,8 +44,10 @@
* not explicitly freed.
*/
-TALLOC_CTX *talloc_stackframe(void);
-TALLOC_CTX *talloc_stackframe_pool(size_t poolsize);
+#define talloc_stackframe() _talloc_stackframe(__location__)
+#define talloc_stackframe_pool(sz) _talloc_stackframe_pool(__location__, (sz))
+TALLOC_CTX *_talloc_stackframe(const char *location);
+TALLOC_CTX *_talloc_stackframe_pool(const char *location, size_t poolsize);
/*
* Get us the current top of the talloc stack.