1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-19 04:59:10 +03:00

python: Allow wrapping pointers within talloc'ed memory that are not talloc contexts.

(This used to be commit 9c038a7411)
This commit is contained in:
Jelmer Vernooij
2008-01-13 20:41:34 +01:00
parent f7a0ef04f0
commit bfab9862fc
3 changed files with 42 additions and 23 deletions

View File

@ -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);