diff options
author | kaa <kaa@disroot.org> | 2025-06-18 03:39:50 -0700 |
---|---|---|
committer | kaa <kaa@disroot.org> | 2025-06-18 03:39:50 -0700 |
commit | c6491196970eb0db837e5a061cbf84c54c4f3539 (patch) | |
tree | 697421903ba0d05cced1a31995533d363d00aa22 /graph.h | |
parent | fc33c79577cf7d6b93898968319fe6b98ec61986 (diff) |
Diffstat (limited to 'graph.h')
-rw-r--r-- | graph.h | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -15,7 +15,7 @@ typedef struct { } Coordinates; bool -valid(Graph2D* g, Coordinates c) +graph_valid(Graph2D* g, Coordinates c) { return c.x >= 0 && c.x < g->width && c.y >= 0 && c.y < g->height; } @@ -23,7 +23,7 @@ valid(Graph2D* g, Coordinates c) /* Reads from the input until exhausted. Returns memory which must be freed by the caller. */ Graph2D* -ingest(FILE* in) +graph_ingest(FILE* in) { char *t = getall(in); char *s = t; @@ -71,3 +71,15 @@ ingest(FILE* in) free(t); return g; } + +void +graph_free(Graph2D* g) +{ + for (int i = 0; i < g->height; i++) { + free(g->e[i]); + free(g->visited[i]); + } + free(g->e); + free(g->visited); + free(g); +} |