summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/maze.c14
-rw-r--r--src/maze.h2
2 files changed, 13 insertions, 3 deletions
diff --git a/src/maze.c b/src/maze.c
index cfa010b..3d62485 100644
--- a/src/maze.c
+++ b/src/maze.c
@@ -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;
}
diff --git a/src/maze.h b/src/maze.h
index 1f22702..c584c35 100644
--- a/src/maze.h
+++ b/src/maze.h
@@ -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_ */