diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-07-01 14:05:17 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2009-07-01 15:15:37 +1000 |
commit | 956b5a0003a3ab82d2d7cffb7aee6e5281b4fbb4 (patch) | |
tree | b31ce346b11cbada4b39dd63134c6a6feb8fe903 /lib/talloc/pytalloc.h | |
parent | 2d981919b8dd63655a39ccaa4fd7bdb39d1830f6 (diff) | |
download | samba-956b5a0003a3ab82d2d7cffb7aee6e5281b4fbb4.tar.gz samba-956b5a0003a3ab82d2d7cffb7aee6e5281b4fbb4.tar.bz2 samba-956b5a0003a3ab82d2d7cffb7aee6e5281b4fbb4.zip |
fixed use of reference in pytalloc
The previous code caused memory leaks, and also caused situations
where talloc_free could be called on pointers with multiple parents
The new approach is to have two functions:
py_talloc_import : steals the pointer, so it becomes wholly owned by
the python object
py_talloc_reference: uses a reference, so it is owned by both python
and C
Diffstat (limited to 'lib/talloc/pytalloc.h')
-rw-r--r-- | lib/talloc/pytalloc.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/talloc/pytalloc.h b/lib/talloc/pytalloc.h index c5a1428b29..00282c4ba0 100644 --- a/lib/talloc/pytalloc.h +++ b/lib/talloc/pytalloc.h @@ -43,6 +43,7 @@ void py_talloc_dealloc(PyObject* self); #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); +PyObject *py_talloc_reference(PyTypeObject *py_type, 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. */ |