diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-05-03 13:41:25 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-05-03 13:41:25 +0300 |
| commit | 6fd2169541269021f4b6d2dd09809f0ced7dc5a3 (patch) | |
| tree | 1ef2d5f2e058dfbbb9d6ec04e52b168a536acf9f | |
| parent | 28158b319a30919310c5d92d9003afac4b5a57f4 (diff) | |
| download | astar-6fd2169541269021f4b6d2dd09809f0ced7dc5a3.tar.xz | |
Fix some memory leaks
| -rw-r--r-- | map.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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); } } |
