summaryrefslogtreecommitdiff
path: root/source4/scripting/python/pytalloc.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-01-13 20:41:34 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-01-14 19:53:05 +0100
commitbfab9862fcdd657a1bddafde49cdd182f89fcf8b (patch)
treedfd64c21365140ad4c7a7741aad3f45270854812 /source4/scripting/python/pytalloc.c
parentf7a0ef04f00cd44845bcee0a171e4cc05a545350 (diff)
downloadsamba-bfab9862fcdd657a1bddafde49cdd182f89fcf8b.tar.gz
samba-bfab9862fcdd657a1bddafde49cdd182f89fcf8b.tar.bz2
samba-bfab9862fcdd657a1bddafde49cdd182f89fcf8b.zip
python: Allow wrapping pointers within talloc'ed memory that are not talloc contexts.
(This used to be commit 9c038a74113fb55ed5eb12a7d0ae4a46bad9050c)
Diffstat (limited to 'source4/scripting/python/pytalloc.c')
-rw-r--r--source4/scripting/python/pytalloc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c
index 4032ff75a4..d0b8cb83f2 100644
--- a/source4/scripting/python/pytalloc.c
+++ b/source4/scripting/python/pytalloc.c
@@ -22,14 +22,16 @@
void py_talloc_dealloc(PyObject* self)
{
py_talloc_Object *obj = (py_talloc_Object *)self;
- talloc_free(obj->talloc_ptr);
+ talloc_free(obj->talloc_ctx);
PyObject_Del(self);
}
-PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr)
+PyObject *py_talloc_import(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
+ void *ptr)
{
PyObject *ret = PyObject_New(py_talloc_Object, &py_type);
- ret->talloc_ptr = talloc_reference(NULL, ptr);
+ ret->talloc_ctx = talloc_reference(mem_ctx, ptr);
+ ret->ptr = ptr;
return ret;
}
@@ -38,5 +40,5 @@ PyObject *py_talloc_default_repr(PyObject *py_obj)
py_talloc_Object *obj = (py_talloc_Object *)py_obj;
return PyString_FromFormat("<talloc: %s>",
- talloc_get_name(obj->talloc_ptr));
+ talloc_get_name(obj->talloc_ctx));
}