diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-04-14 04:49:29 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-04-14 04:49:29 +0000 |
commit | 31d5f7f15c383cf527e2ae406f96f94d8a1267b1 (patch) | |
tree | 8c945ba43018acd58e93e3e0bfb9fa305c223cfd | |
parent | 1060174a2451d4b94cb2cc59ba74900cf08f43a6 (diff) |
Sat, Apr 13, 2024, 9:49 PM -07:00
-rw-r--r-- | wk5/pset/inheritance/inheritance.c | 10 |
1 files changed, 9 insertions, 1 deletions
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 } |