From 31d5f7f15c383cf527e2ae406f96f94d8a1267b1 Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Sun, 14 Apr 2024 04:49:29 +0000 Subject: Sat, Apr 13, 2024, 9:49 PM -07:00 --- wk5/pset/inheritance/inheritance.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'wk5/pset/inheritance') diff --git a/wk5/pset/inheritance/inheritance.c b/wk5/pset/inheritance/inheritance.c index 912a461..9e7a211 100644 --- a/wk5/pset/inheritance/inheritance.c +++ b/wk5/pset/inheritance/inheritance.c @@ -80,9 +80,17 @@ person *create_family(int generations) void free_family(person *p) { // TODO: Handle base case - free(p) + if (p->parent[0] == NULL) + { + free(*p); + } // TODO: Free parents recursively + if (p->parent[0] != NULL) + { + free_family(p->parent[0]); + free_family(p->parent[1]); + } // TODO: Free child } -- cgit v1.2.3