diff options
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); +} |
