diff options
Diffstat (limited to 'source4/lib/talloc/talloc.c')
-rw-r--r-- | source4/lib/talloc/talloc.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c index 6b6eb87f21..c6f748ea3b 100644 --- a/source4/lib/talloc/talloc.c +++ b/source4/lib/talloc/talloc.c @@ -1108,3 +1108,27 @@ size_t talloc_get_size(const void *context) return tc->size; } + +/* + find a parent of this context that has the given name, if any +*/ +void *talloc_find_parent_byname(const void *context, const char *name) +{ + struct talloc_chunk *tc; + + if (context == NULL) { + return NULL; + } + + tc = talloc_chunk_from_ptr(context); + while (tc->prev) { + tc = tc->prev; + } + while (tc->parent && (!tc->name || strcmp(tc->name, name))) { + tc = tc->parent; + } + if (tc == NULL) { + return NULL; + } + return (void *)(tc+1); +} |