I'm trying to free mem from 2 dimensional array the same way like in this: [C: Correctly freeing memory of a multi-dimensional array
//initialization
int **tab;
int i,j;
int x_max=5,y_max=7;
tab = calloc(x_max+1, sizeof(int));
for(j = 0; j <=x_max+1; j++)
{
tab[j] = calloc(y_max+2, sizeof(int));
}
and than:
for (i = 0; i <=x_max+1; i++)
{
free(tab[i]);
}
free(tab);
This seems to be like in the example in above link, but my program keeps crashing (when I comment freeing mem part everything works good.) Also when I try to debug program line by line everything works. (Debugger finished with status 0)