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.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c
index e05b196592..f6f7e899d1 100644
--- a/source4/lib/talloc/talloc.c
+++ b/source4/lib/talloc/talloc.c
@@ -424,6 +424,23 @@ const char *talloc_get_name(const void *ptr)
return "UNNAMED";
}
+
+/*
+ check if a pointer has the given name. If it does, return the pointer,
+ otherwise return NULL
+*/
+void *talloc_check_name(const void *ptr, const char *name)
+{
+ const char *pname;
+ if (ptr == NULL) return NULL;
+ pname = talloc_get_name(ptr);
+ if (pname == name || strcmp(pname, name) == 0) {
+ return discard_const_p(void, ptr);
+ }
+ return NULL;
+}
+
+
/*
this is for compatibility with older versions of talloc
*/
@@ -1029,3 +1046,5 @@ void *talloc_autofree_context(void)
}
return cleanup_context;
}
+
+