diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2009-09-28 15:03:17 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2009-09-28 15:03:17 +0200 |
commit | 830adcd58d6b1fbc3e693762ab2e8a8cfd7ecab3 (patch) | |
tree | 4794e4679b0182932c12e8d7b63789ba5dc1ca7f | |
parent | 5c0edba8c2ade663d630a3b9f3ff0c4862129783 (diff) | |
download | samba-830adcd58d6b1fbc3e693762ab2e8a8cfd7ecab3.tar.gz samba-830adcd58d6b1fbc3e693762ab2e8a8cfd7ecab3.tar.bz2 samba-830adcd58d6b1fbc3e693762ab2e8a8cfd7ecab3.zip |
pidl: Avoid using talloc_free as function pointer, since it may be a
macro.
-rw-r--r-- | lib/talloc/pytalloc.c | 10 | ||||
-rw-r--r-- | lib/talloc/pytalloc.h | 2 | ||||
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/Python.pm | 4 |
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"); |