======
SOLVED
======
Hi errbody!
Doing this school assignment, and i need some advice/help with freeing an array of dynamic allocated memory.
Code:
void freeMem(game *GoL){
int i,j;
for(i = 0; i < (*GoL).rows; i++){
for(j = 0; j < (*GoL).cols; j++){
free((*GoL).field[i][j].current);
printf("Freeing row: [%d]\n", i);
}
}
printf("--------------\nFreeing array, done!\n");
free((*GoL).field);
}
Im writing a GoL game, and one of the demands of the assignments is that we have to free the dynamic allocated memory after the user has aborted the game. This code is at the end of my program and im getting this error:
Code:
lab3.c: In function `freeMem':
lab3.c:249: warning: passing arg 1 of `free' makes pointer from integer without a cast
I've been googling around for an hour or two. But most of them tells me that i need to first free every point, then every row and after that the whole array.
So i need help/advice on why this isnt working
Thanks!