i have a memory leak issue with extension function that im working on.
it reads data from a binary file into a stl vector then creates a new
list to pass back to the python interface. the function works the first
1021 times but then gives a segmentation fault (core dumped). heres the
business part of the code:<br>
<br>
<br>
//read data<br>
vector<float> data;<br>
float temp;<br>
<br>
for(int x=0;x<np*2;x++)<br>
{<br>
fread(&temp,sizeof(float),1,datfil);<br>
data.push_back(temp);<br>
}<br>
<br>
//convert vector to list<br>
PyObject *newlist = PyList_New(np*2);<br>
PyList_SetItem(newlist, 0,PyFloat_FromDouble(data[0]));<br>
for(int x=0;x<np*2;x++)<br>
{<br>
PyList_SetItem(newlist, x,PyFloat_FromDouble(data[x]));<br>
}<br>
<br>
<br>
<br>
//send back list<br>
return newlist;<br>
<br>
thanks for any advice<br>