summaryrefslogtreecommitdiff
path: root/wk5
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-04-14 04:49:29 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-04-14 04:49:29 +0000
commit31d5f7f15c383cf527e2ae406f96f94d8a1267b1 (patch)
tree8c945ba43018acd58e93e3e0bfb9fa305c223cfd /wk5
parent1060174a2451d4b94cb2cc59ba74900cf08f43a6 (diff)
Sat, Apr 13, 2024, 9:49 PM -07:00
Diffstat (limited to 'wk5')
-rw-r--r--wk5/pset/inheritance/inheritance.c10
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
}