mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
talloc: add _pytalloc_get_ptr/_pytalloc_get_mem_ctx helper functions
This allows us to check which type is involved, and dereference that type correctly Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
parent
cd8d930021
commit
42eae4dec6
@ -42,8 +42,10 @@ int pytalloc_Check(PyObject *);
|
||||
* when talloc_get_type() returns NULL. */
|
||||
#define pytalloc_get_type(py_obj, type) (talloc_get_type(pytalloc_get_ptr(py_obj), type))
|
||||
|
||||
#define pytalloc_get_ptr(py_obj) (((pytalloc_Object *)py_obj)->ptr)
|
||||
#define pytalloc_get_mem_ctx(py_obj) ((pytalloc_Object *)py_obj)->talloc_ctx
|
||||
void *_pytalloc_get_ptr(PyObject *py_obj);
|
||||
#define pytalloc_get_ptr(py_obj) _pytalloc_get_ptr((PyObject *)(py_obj))
|
||||
TALLOC_CTX *_pytalloc_get_mem_ctx(PyObject *py_obj);
|
||||
#define pytalloc_get_mem_ctx(py_obj) _pytalloc_get_mem_ctx((PyObject *)(py_obj))
|
||||
|
||||
PyObject *pytalloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
|
||||
PyObject *pytalloc_steal(PyTypeObject *py_type, void *ptr);
|
||||
|
@ -120,3 +120,13 @@ _PUBLIC_ int pytalloc_Check(PyObject *obj)
|
||||
|
||||
return PyObject_TypeCheck(obj, tp);
|
||||
}
|
||||
|
||||
_PUBLIC_ void *_pytalloc_get_ptr(PyObject *py_obj)
|
||||
{
|
||||
return ((pytalloc_Object *)py_obj)->ptr;
|
||||
}
|
||||
|
||||
_PUBLIC_ TALLOC_CTX *_pytalloc_get_mem_ctx(PyObject *py_obj)
|
||||
{
|
||||
return ((pytalloc_Object *)py_obj)->talloc_ctx;
|
||||
}
|
||||
|
@ -43,13 +43,13 @@ static PyObject *testpytalloc_get_object_type(PyObject *mod) {
|
||||
}
|
||||
|
||||
static PyObject *testpytalloc_reference(PyObject *mod, PyObject *args) {
|
||||
pytalloc_Object *source = NULL;
|
||||
PyObject *source = NULL;
|
||||
void *ptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!", pytalloc_GetObjectType(), &source))
|
||||
return NULL;
|
||||
|
||||
ptr = source->ptr;
|
||||
ptr = pytalloc_get_ptr(source);
|
||||
return pytalloc_reference_ex(pytalloc_GetObjectType(), ptr, ptr);
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ def build(bld):
|
||||
vnum=VERSION,
|
||||
hide_symbols=True,
|
||||
abi_directory='ABI',
|
||||
abi_match='pytalloc_*',
|
||||
abi_match='pytalloc_* _pytalloc_*',
|
||||
private_library=private_library,
|
||||
public_headers=('' if private_library else 'pytalloc.h'),
|
||||
pc_files='pytalloc-util.pc'
|
||||
|
Loading…
x
Reference in New Issue
Block a user