summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/talloc/pytalloc.c10
-rw-r--r--lib/talloc/pytalloc.h2
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm4
3 files changed, 14 insertions, 2 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_ */
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index eb8bd31873..c785619adb 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -998,10 +998,10 @@ sub ConvertScalarToPython($$$)
}
# Not yet supported
- if ($ctypename eq "string_array") { return "PyCObject_FromVoidPtr($cvar, talloc_free)"; }
+ if ($ctypename eq "string_array") { return "PyCObject_FromTallocPtr($cvar)"; }
if ($ctypename eq "ipv4address") { return "PyString_FromString($cvar)"; }
if ($ctypename eq "pointer") {
- return "PyCObject_FromVoidPtr($cvar, talloc_free)";
+ return "PyCObject_FromTallocPtr($cvar)";
}
die("Unknown scalar type $ctypename");