destroyGrid() frees grid contents and itself.

This commit is contained in:
Sheldon Lee
2020-06-27 01:20:49 +01:00
parent 00ffe88289
commit ee5c58ad81
2 changed files with 12 additions and 1 deletions
+9 -1
View File
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <ncurses.h>
#include <stdlib.h>
#include <time.h>
#include <ncurses.h>
#include "grid.h"
// locally used declaration
@@ -78,6 +79,13 @@ void drawGrid(Grid* grid)
}
}
void destroyGrid(Grid* grid)
{
free(grid->state);
free(grid->next_state);
free(grid);
printf("Grid destroyed\n");
}
// locally used
// check if cell's next state is alive
static bool isAliveNext(Grid* grid, int x, int y)