Skip to content

Commit

Permalink
Fixed memory leak when using to_array() in python
Browse files Browse the repository at this point in the history
  • Loading branch information
pariterre committed Feb 15, 2024
1 parent 385f8f9 commit 14c054a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions binding/python3/biorbd_python.i.in
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
}
PyObject* output = PyArray_SimpleNewFromData(nArraySize,arraySizes,NPY_DOUBLE, quat);
PyArray_ENABLEFLAGS((PyArrayObject *)output, NPY_ARRAY_OWNDATA);
delete[] arraySizes;
return output;
};
#endif
Expand Down Expand Up @@ -289,6 +290,7 @@
}
PyObject* output = PyArray_SimpleNewFromData(nArraySize,arraySizes,NPY_DOUBLE, matrix);
PyArray_ENABLEFLAGS((PyArrayObject *)output, NPY_ARRAY_OWNDATA);
delete[] arraySizes;
return output;
};

Expand Down Expand Up @@ -379,6 +381,7 @@
}
PyObject* output = PyArray_SimpleNewFromData(nArraySize,arraySizes,NPY_DOUBLE, matrix);
PyArray_ENABLEFLAGS((PyArrayObject *)output, NPY_ARRAY_OWNDATA);
delete[] arraySizes;
return output;
};

Expand Down Expand Up @@ -450,6 +453,7 @@
}
PyObject* output = PyArray_SimpleNewFromData(nArraySize,arraySizes,NPY_DOUBLE, vect);
PyArray_ENABLEFLAGS((PyArrayObject *)output, NPY_ARRAY_OWNDATA);
delete[] arraySizes;
return output;
};
#endif
Expand Down Expand Up @@ -1020,6 +1024,7 @@ BIORBD_NAMESPACE::utils::Vector3d &{
}
PyObject* output = PyArray_SimpleNewFromData(nArraySize,arraySizes,NPY_DOUBLE, node);
PyArray_ENABLEFLAGS((PyArrayObject *)output, NPY_ARRAY_OWNDATA);
delete[] arraySizes;
return output;
}
#endif
Expand All @@ -1043,6 +1048,7 @@ BIORBD_NAMESPACE::utils::Vector3d &{
}
PyObject* output = PyArray_SimpleNewFromData(nArraySize,arraySizes,NPY_DOUBLE, node);
PyArray_ENABLEFLAGS((PyArrayObject *)output, NPY_ARRAY_OWNDATA);
delete[] arraySizes;
return output;
}
#endif
Expand Down Expand Up @@ -1129,6 +1135,7 @@ BIORBD_NAMESPACE::utils::Vector3d &{
}
PyObject* output = PyArray_SimpleNewFromData(nArraySize,arraySizes,NPY_DOUBLE, values);
PyArray_ENABLEFLAGS((PyArrayObject *)output, NPY_ARRAY_OWNDATA);
delete[] arraySizes;
return output;
}

Expand Down Expand Up @@ -1158,6 +1165,7 @@ BIORBD_NAMESPACE::utils::Vector3d &{
}
PyObject* output = PyArray_SimpleNewFromData(nArraySize,arraySizes,NPY_DOUBLE, values);
PyArray_ENABLEFLAGS((PyArrayObject *)output, NPY_ARRAY_OWNDATA);
delete[] arraySizes;
return output;
}
#endif
Expand All @@ -1183,6 +1191,7 @@ BIORBD_NAMESPACE::utils::Vector3d &{
}
PyObject* output = PyArray_SimpleNewFromData(nArraySize,arraySizes,NPY_DOUBLE, values);
PyArray_ENABLEFLAGS((PyArrayObject *)output, NPY_ARRAY_OWNDATA);
delete[] arraySizes;
return output;
}

Expand Down

0 comments on commit 14c054a

Please sign in to comment.