fix memory leaks for module init/end and kwargs
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7991 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e439095816
commit
3665385cb5
1 changed files with 7 additions and 7 deletions
|
|
@ -195,7 +195,7 @@ PySwigClientData_New(PyObject* obj)
|
||||||
if (data->destroy) {
|
if (data->destroy) {
|
||||||
Py_INCREF(data->destroy);
|
Py_INCREF(data->destroy);
|
||||||
int flags = PyCFunction_GET_FLAGS(data->destroy);
|
int flags = PyCFunction_GET_FLAGS(data->destroy);
|
||||||
data->delargs = (flags & (METH_VARARGS));
|
data->delargs = !(flags & (METH_O));
|
||||||
} else {
|
} else {
|
||||||
data->delargs = 0;
|
data->delargs = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -332,16 +332,14 @@ PySwigObject_dealloc(PyObject *v)
|
||||||
if (destroy) {
|
if (destroy) {
|
||||||
/* destroy is always a VARARGS method */
|
/* destroy is always a VARARGS method */
|
||||||
PyObject *res;
|
PyObject *res;
|
||||||
PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
|
|
||||||
PyObject *mself = PyCFunction_GET_SELF(destroy);
|
|
||||||
if (data->delargs) {
|
if (data->delargs) {
|
||||||
/* we need to create a temporal object to carry the destroy operation */
|
/* we need to create a temporal object to carry the destroy operation */
|
||||||
PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
|
PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
|
||||||
PyObject *args = PyTuple_New(1);
|
res = PyObject_CallFunctionObjArgs(destroy, tmp, NULL);
|
||||||
PyTuple_SetItem(args,0,tmp);
|
Py_DECREF(tmp);
|
||||||
res = ((*meth)(mself, args));
|
|
||||||
Py_DECREF(args);
|
|
||||||
} else {
|
} else {
|
||||||
|
PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
|
||||||
|
PyObject *mself = PyCFunction_GET_SELF(destroy);
|
||||||
res = ((*meth)(mself, v));
|
res = ((*meth)(mself, v));
|
||||||
}
|
}
|
||||||
Py_XDECREF(res);
|
Py_XDECREF(res);
|
||||||
|
|
@ -1039,6 +1037,8 @@ SWIG_Python_SetModule(swig_module_info *swig_module) {
|
||||||
PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
|
PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
|
||||||
if (pointer && module) {
|
if (pointer && module) {
|
||||||
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
|
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
|
||||||
|
} else {
|
||||||
|
Py_XDECREF(pointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue