diff options
-rw-r--r-- | src/maze.c | 14 | ||||
-rw-r--r-- | src/maze.h | 2 |
2 files changed, 13 insertions, 3 deletions
@@ -179,8 +179,18 @@ mf_maze_new(int s, int w, int h) } void -mf_maze_free(struct mf_maze *m) +mf_maze_destroy(struct mf_maze **m_p) { - free(m->walls); + struct mf_maze *m; + + if (m_p == NULL || *m_p == NULL) { + return; + } + m = *m_p; + + if (m->walls != NULL) { + free(m->walls); + } free(m); + m = NULL; } @@ -33,6 +33,6 @@ struct mf_maze * mf_maze_new(int s, int w, int h); void -mf_maze_free(struct mf_maze *m); +mf_maze_destroy(struct mf_maze **m_p); #endif /* MF_MAZE_H_ */ |