diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-26 13:42:59 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-26 13:42:59 +0300 |
| commit | 0a6f8b49723aa8da143953bc011582542d2f2010 (patch) | |
| tree | d2fb6216ff0815a8539d3b315e188181e98bbf89 /path.c | |
| parent | 5bf01bf1955cb1be6dc498543f8b2064b3424177 (diff) | |
| download | astar-0a6f8b49723aa8da143953bc011582542d2f2010.tar.xz | |
Fix memory leaks
Diffstat (limited to 'path.c')
| -rw-r--r-- | path.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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); +} |
