aboutsummaryrefslogtreecommitdiff
path: root/booki.c
diff options
context:
space:
mode:
authorBen Winston2024-05-28 20:34:25 -0400
committerBen Winston2024-05-28 20:34:25 -0400
commit6f52b2fb97db698fd1616fb6c26901b966f8989b (patch)
tree52515c8ae1c5e21c5e544b01b8a8a9a119c55497 /booki.c
parent2465fef44a6aa503d774a40ccdf9ea2272c1e85a (diff)
free the list after it's been used
Diffstat (limited to 'booki.c')
-rw-r--r--booki.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/booki.c b/booki.c
index eb01ca1..843ed9b 100644
--- a/booki.c
+++ b/booki.c
@@ -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);