Skip to content

Commit

Permalink
memory leak fix; Py_XDCREF amp_func set to NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
hammy4815 committed Feb 9, 2023
1 parent b86b476 commit 439ee78
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/meep.i
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ meep::volume_list *make_volume_list(const meep::volume &v, int c,

%typemap(freearg) double (*)(const meep::vec &) {
Py_XDECREF(py_callback);
py_callback = NULL;
}

%typecheck(SWIG_TYPECHECK_POINTER) double (*)(const meep::vec &) {
Expand All @@ -738,6 +739,7 @@ meep::volume_list *make_volume_list(const meep::volume &v, int c,

%typemap(freearg) std::complex<double> (*)(const meep::vec &) {
Py_XDECREF(py_amp_func);
py_amp_func = NULL;
}

// Typemap suite for vector3
Expand Down Expand Up @@ -1050,6 +1052,7 @@ void _get_gradient(PyObject *grad, double scalegrad,

%typemap(freearg) std::complex<double> (*)(const meep::vec &) {
Py_XDECREF(py_amp_func);
py_amp_func = NULL;
}

%typecheck(SWIG_TYPECHECK_POINTER) PyObject *min_max_loc {
Expand Down

0 comments on commit 439ee78

Please sign in to comment.