aboutsummaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
Diffstat (limited to 'path.c')
-rw-r--r--path.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/path.c b/path.c
index 37f2dbf..6f00ee8 100644
--- a/path.c
+++ b/path.c
@@ -38,6 +38,7 @@ Path breadth_first_search_path_4dir(Map map, size_t width, size_t height, Positi
visited[cur.y][cur.x] = 1;
if (cur.x == end.x && cur.y == end.y) {
+ ppq_free(frontier);
return path; /* Found path */
}
@@ -79,6 +80,7 @@ Path breadth_first_search_path_8dir(Map map, size_t width, size_t height, Positi
visited[cur.y][cur.x] = 1;
if (cur.x == end.x && cur.y == end.y) {
+ ppq_free(frontier);
return path; /* Found path */
}
@@ -136,3 +138,11 @@ size_t manhattan_distance(Position a, Position b) {
}
return d;
}
+
+void path_free(Path path, size_t height) {
+ if (path == NULL) return;
+ for (size_t i = 0; i < height; i++) {
+ free(path[i]);
+ }
+ free(path);
+}