diff options
| author | Ben Winston | 2024-05-28 20:34:25 -0400 |
|---|---|---|
| committer | Ben Winston | 2024-05-28 20:34:25 -0400 |
| commit | 6f52b2fb97db698fd1616fb6c26901b966f8989b (patch) | |
| tree | 52515c8ae1c5e21c5e544b01b8a8a9a119c55497 /booki.c | |
| parent | 2465fef44a6aa503d774a40ccdf9ea2272c1e85a (diff) | |
free the list after it's been used
Diffstat (limited to 'booki.c')
| -rw-r--r-- | booki.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -514,6 +514,17 @@ void open(char* filepath) { } } +void free_book(struct Book book) { + // any string can be a list of strings + struct es* str = book.author.next; + struct es* tmp; + while (str != NULL) { + tmp = str->next; + free(str); + str = tmp; + } +} + void search(int argc, char* argv[], char* booki_file) { struct search_opt search_opts = parse_search_options(argc, argv); @@ -583,6 +594,7 @@ void search(int argc, char* argv[], char* booki_file) { } else if (search_opts.edit) { write_book(book, fixed_file); } + free_book(book); } free(data); |
