summaryrefslogtreecommitdiff
path: root/source4/scripting/python/pytalloc.h
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.h
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.h')
-rw-r--r--source4/scripting/python/pytalloc.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/source4/scripting/python/pytalloc.h b/source4/scripting/python/pytalloc.h
index 735829bfcb..aad5840a67 100644
--- a/source4/scripting/python/pytalloc.h
+++ b/source4/scripting/python/pytalloc.h
@@ -24,7 +24,8 @@
typedef struct {
PyObject_HEAD
- void *talloc_ptr;
+ TALLOC_CTX *talloc_ctx;
+ void *ptr;
} py_talloc_Object;
/* Deallocate a py_talloc_Object */
@@ -36,9 +37,13 @@ void py_talloc_dealloc(PyObject* self);
/* FIXME: Call PyErr_SetString(PyExc_TypeError, "expected " __STR(type) ")
* when talloc_get_type() returns NULL. */
#define py_talloc_get_type(py_obj, type) \
- talloc_get_type(((py_talloc_Object *)py_obj)->talloc_ptr, type)
+ talloc_get_type(py_talloc_get_ptr(py_obj), type)
-PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr);
+#define py_talloc_get_ptr(py_obj) ((py_talloc_Object *)py_obj)->ptr
+#define py_talloc_get_mem_ctx(py_obj) ((py_talloc_Object *)py_obj)->talloc_ctx
+
+PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
+#define py_talloc_import(py_type, talloc_ptr) py_talloc_import_ex(py_type, talloc_ptr, talloc_ptr)
/* Sane default implementation of reprfunc. */
PyObject *py_talloc_default_repr(PyObject *py_obj);