diff options
Diffstat (limited to 'wk5/pset/inheritance/inheritance.c')
-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 } |