mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
pytalloc: fixed py_talloc_steal()
py_talloc_steal() was implemented as a macro which evaluated it's 2nd argument twice. It was often called via a macro with a 2nd argument that was a function call, for example an allocation in py_talloc_new(). This meant it allocated memory twice, and leaked one of them. This re-implements py_talloc_steal() as a function, so that it only does the allocation once.
This commit is contained in:
parent
9218de4b74
commit
634e06e465
@ -52,6 +52,14 @@ PyObject *py_talloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import an existing talloc pointer into a Python object.
|
||||
*/
|
||||
PyObject *py_talloc_steal(PyTypeObject *py_type, void *ptr)
|
||||
{
|
||||
return py_talloc_steal_ex(py_type, ptr, ptr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Import an existing talloc pointer into a Python object, leaving the
|
||||
|
@ -43,8 +43,8 @@ void py_talloc_dealloc(PyObject* self);
|
||||
#define py_talloc_get_mem_ctx(py_obj) ((py_talloc_Object *)py_obj)->talloc_ctx
|
||||
|
||||
PyObject *py_talloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
|
||||
PyObject *py_talloc_steal(PyTypeObject *py_type, void *ptr);
|
||||
PyObject *py_talloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
|
||||
#define py_talloc_steal(py_type, talloc_ptr) py_talloc_steal_ex(py_type, talloc_ptr, talloc_ptr)
|
||||
#define py_talloc_reference(py_type, talloc_ptr) py_talloc_reference_ex(py_type, talloc_ptr, talloc_ptr)
|
||||
|
||||
/* Sane default implementation of reprfunc. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user