This is my code for Python Wrapper for C function doing some simple calculation with Rotation matrix and Vectors. My function is transform_object
, but it's not causing the problem (I was debuging it also without executing this func).
static PyObject* method_transform(PyObject* self, PyObject* args) {
double or1, or2, or3;
double cd1, cd2, cd3;
double ang1, ang2, ang3;
if (!PyArg_ParseTuple(args, "(ddd)(ddd)(ddd)", &or1, &or2, &or3, &cd1, &cd2, &cd3, &ang1, &ang2, &ang3)) {
return NULL;
}
double or[3] = { or1, or2, or3 };
double cd[3] = { cd1, cd2, cd3 };
double ang[3] = { ang1, ang2, ang3 };
double* vector = transform_object(or , cd, ang);
PyObject* list = PyList_New(0);
int len = 3;
for (int i = 0; i < len; i++) {
PyObject* the_object = PyFloat_FromDouble(vector[i]);
PyList_Append(list, the_object);
}
return list;
}
And I have a problem with memory leak, I supose. It's going to infinity.
I tried to commenting line by line and found that problem is in this line:
PyObject* the_object = PyFloat_FromDouble(vector[i]);
If I repleace vector[i]
with for eg. or1
it's the same problem.
But I don't know why, there are any limitations to making PyObjects
from arrays or something?