Hi guys,
I am using some a piece of code that blows up the memory usage. The function is the following
Code:
static double ** matrix(int nrh, int nch)
{
int i;
double **m;
m = (double **) calloc((nrh + 1), sizeof(double *));
for (i = 0; i <= nrh; i++)
m[i] = (double*) calloc((nch + 1), sizeof(double));
return m;
}
and it is used inside another function (let's say "func") that it is called repeatdly in the main program. In particular inside this function the former is used as follows
Code:
double func()
{
int n=1;
double **P
P=matrix(n, n+1);
}
I guess that the problem is that P is not freed at the end of func. I have tried free(P), but of course it did not work. Somebody can help me?
Thank you!