summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/talloc/pytalloc.c10
-rw-r--r--lib/talloc/pytalloc.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c
index 646aac87f2..c6decf33f1 100644
--- a/lib/talloc/pytalloc.c
+++ b/lib/talloc/pytalloc.c
@@ -81,3 +81,13 @@ PyObject *py_talloc_default_repr(PyObject *obj)
return PyString_FromFormat("<%s talloc object at 0x%p>",
type->tp_name, talloc_obj->ptr);
}
+
+static void py_cobject_talloc_free(void *ptr)
+{
+ talloc_free(ptr);
+}
+
+PyObject *PyCObject_FromTallocPtr(void *ptr)
+{
+ return PyCObject_FromVoidPtr(ptr, py_cobject_talloc_free);
+}
diff --git a/lib/talloc/pytalloc.h b/lib/talloc/pytalloc.h
index 3bfb272958..9b6587261c 100644
--- a/lib/talloc/pytalloc.h
+++ b/lib/talloc/pytalloc.h
@@ -52,4 +52,6 @@ PyObject *py_talloc_default_repr(PyObject *py_obj);
#define py_talloc_new(type, typeobj) py_talloc_steal(typeobj, talloc_zero(NULL, type))
+PyObject *PyCObject_FromTallocPtr(void *);
+
#endif /* _PY_TALLOC_H_ */