summaryrefslogtreecommitdiff
path: root/source4/lib/talloc/talloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/talloc/talloc.c')
-rw-r--r--source4/lib/talloc/talloc.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c
index bae1942f43..dafb6d9075 100644
--- a/source4/lib/talloc/talloc.c
+++ b/source4/lib/talloc/talloc.c
@@ -164,8 +164,15 @@ do { \
*/
static struct talloc_chunk *talloc_parent_chunk(const void *ptr)
{
- struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
+ struct talloc_chunk *tc;
+
+ if (unlikely(ptr == NULL)) {
+ return NULL;
+ }
+
+ tc = talloc_chunk_from_ptr(ptr);
while (tc->prev) tc=tc->prev;
+
return tc->parent;
}
@@ -178,23 +185,12 @@ void *talloc_parent(const void *ptr)
/*
find parents name
*/
-const char *talloc_parent_name(const void *context)
+const char *talloc_parent_name(const void *ptr)
{
- struct talloc_chunk *tc;
-
- if (unlikely(context == NULL)) {
- return NULL;
- }
-
- tc = talloc_chunk_from_ptr(context);
- while (tc && tc->prev) tc = tc->prev;
- if (tc) {
- tc = tc->parent;
- }
- return tc->name;
+ struct talloc_chunk *tc = talloc_parent_chunk(ptr);
+ return tc? tc->name : NULL;
}
-
/*
Allocate a bit of memory as a child of an existing pointer
*/