|
I keep running in to segmentation faults when running this Mex file, but it is sporadic and cannot be predicted. The problem comes from the following bit of code:
for (j =0; j<t->neighbors; j++) {
...
ccv_contour_t* cont = t->letters[j]->contour;
mxArray* S = mxCreateDoubleMatrix(cont->size, 1, mxREAL); //THIS IS THE PROBLEM LINE
}
Leaving out the mxArray* line, everything works perfectly, however when adding in the line causes the variable cont to sometimes be NULL for some iterations of the loop. I'd say this behaviour happens around 50% of the times I run the exact same code.
It must be something to do with the memory allocated, but I can't figure out what is wrong (and I have spent hours on this now...)
|