In the main function, I have some null pointer like
double *data_1;
This pointers are passed as argument to other function which determine how many components must have data_1 and uses malloc to assign a memory block and store information:
void function(double *data) {
...
data = (double *) malloc((size_t) (Ndata) * sizeof(double));
for(i = 0; i < (Ndata); i++) {
data[i] = sys->points[i][coordinate];
}
}
This code isn't working. I used GDB to examine bug and I encounter that inside function() the assignment works, but when execution returns to the main() function, the array data_1 wasn't modified although the memory to which it points is exactly the same to which points "data" argument in function().
Why is this happening?