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