aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-05-03 13:41:25 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-05-03 13:41:25 +0300
commit6fd2169541269021f4b6d2dd09809f0ced7dc5a3 (patch)
tree1ef2d5f2e058dfbbb9d6ec04e52b168a536acf9f
parent28158b319a30919310c5d92d9003afac4b5a57f4 (diff)
downloadastar-6fd2169541269021f4b6d2dd09809f0ced7dc5a3.tar.xz
Fix some memory leaks
-rw-r--r--map.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/map.c b/map.c
index a5e528c..03e69f5 100644
--- a/map.c
+++ b/map.c
@@ -819,7 +819,10 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi
if (row < *height && col < *width && (*map)[row][col] != WALL && (col != goal->x || row != goal->y)) {
start->x = col;
start->y = row;
- if (should_pathfind) path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0);
+ if (should_pathfind) {
+ path_free(path, *height);
+ path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0);
+ }
draw_map(*map, NULL, *width, *height, *start, *goal, NULL, path, visited, NULL);
}
}
@@ -830,7 +833,10 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi
if (row < *height && col < *width && (*map)[row][col] != WALL && (col != start->x || row != start->y)) {
goal->x = col;
goal->y = row;
- if (should_pathfind) path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0);
+ if (should_pathfind) {
+ path_free(path, *height);
+ path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0);
+ }
draw_map(*map, NULL, *width, *height, *start, *goal, NULL, path, visited, NULL);
}
}