aboutsummaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-03-26 13:42:59 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-03-26 13:42:59 +0300
commit0a6f8b49723aa8da143953bc011582542d2f2010 (patch)
treed2fb6216ff0815a8539d3b315e188181e98bbf89 /path.c
parent5bf01bf1955cb1be6dc498543f8b2064b3424177 (diff)
downloadastar-0a6f8b49723aa8da143953bc011582542d2f2010.tar.xz
Fix memory leaks
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);
+}