From 0a6f8b49723aa8da143953bc011582542d2f2010 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Thu, 26 Mar 2026 13:42:59 +0300 Subject: Fix memory leaks --- path.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'path.c') 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); +} -- cgit v1.2.3