Code:
int main ()
{
...
double* convlvData;
double *x_input, *y_input, *x_inputPad, *y_inputPad, *y_input_cmplx, *y_input_fft;
int len_input, len_input_cmplx, len_inputPad;
double *x_resp, *x_respW, *y_resp, *y_respW, *y_resp_cmplx, *y_resp_fft;
int len_resp, len_resp_cmplx; //len resp must be less than len_data, someone validate for this please.
...
if (statusFlag != 0) statusFlag = wrap(x_resp, &x_respW, y_resp, &y_respW, len_resp, len_input, &DataPadRef);
showMessage(" Padding Data... ", 1);
if (statusFlag != 0) statusFlag = convlvDataPad(x_input, y_input, &x_inputPad, &y_inputPad, DataPadRef, len_input);
//The crash happens within convlvDataPad
...
}
int wrap(double* x_resp, double** x_respW, double* y_resp, double** y_respW, int len_resp, int len_input, int *DataPadRef)
{
...
statusFlag = buildArray ( x_respW , (len_input) );
statusFlag = statusFlag && buildArray ( y_respW , (len_input) );
...
}
//I.e Wrap contains some array creation.
int convlvDataPad(double* data_x, double* data_y, double** paddata_x, double** paddata_y, int DataPadRef, int len_input)
{
...
statusFlag = buildArray ( paddata_x , padLen);
//CRASH OCCURS IN ABOVE FUNCTION
statusFlag = statusFlag && buildArray ( paddata_y , padLen);
...
}
int buildArray ( double** array, int size )
{
int statusFlag = 1;
showMessage(" (buildArray) Enter BuildArray... ", 1);
*array = ( double* ) malloc ( sizeof ( double ) * size );
//CRASH HAPPENS HERE IN CALL FROM CONVLV DATA DURING MALLOC LINE
showMessage(" (buildArray) Malloc finished... ", 1);
statusFlag = ( *array != NULL );
checkError ( statusFlag , "Memory allocation has failed (buildArray)." , 0 );
return statusFlag;
}