fix memory PyObject * typemaps to avoid memory leaks with iterators
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8375 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
07011f2e95
commit
5daf66c0db
4 changed files with 30 additions and 4 deletions
|
|
@ -42,6 +42,18 @@ namespace swig {
|
|||
struct PyObject_ptr {};
|
||||
%apply PyObject * {PyObject_ptr};
|
||||
%apply PyObject * const& {PyObject_ptr const&};
|
||||
|
||||
/* For output */
|
||||
%typemap(out,noblock=1) PyObject_ptr {
|
||||
$result = (PyObject *)$1;
|
||||
Py_INCREF($result);
|
||||
}
|
||||
|
||||
%typemap(out,noblock=1) PyObject_ptr const & {
|
||||
$result = (PyObject *)*$1;
|
||||
Py_INCREF($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue