L
luca
I allocate memory using a double pointer (to double values).
double** chOut = (double**) calloc ( nCol , sizeof(double*) );
for (int x = 0 ; x < nCol ; x++)
chOut[x] = (double*) calloc (nRow, sizeof(double));
What do I have to do in order to correctly free all the allocated memory?
1)
free(chOut);
Is it enough? Do I have to free each row before freeing chOut?
2)
for (int x = 0 ; x < nCol ; x++)
free(chOut[x]);
free(chOut);
Thanks
Luca.
double** chOut = (double**) calloc ( nCol , sizeof(double*) );
for (int x = 0 ; x < nCol ; x++)
chOut[x] = (double*) calloc (nRow, sizeof(double));
What do I have to do in order to correctly free all the allocated memory?
1)
free(chOut);
Is it enough? Do I have to free each row before freeing chOut?
2)
for (int x = 0 ; x < nCol ; x++)
free(chOut[x]);
free(chOut);
Thanks
Luca.