From 17420609eaf0c3c708248a3a7fb4a89aa12a2c1a Mon Sep 17 00:00:00 2001 From: Ben Winston Date: Tue, 28 May 2024 21:29:25 -0400 Subject: support lists of translators and languages --- booki.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'booki.c') diff --git a/booki.c b/booki.c index adecca2..4aaea81 100644 --- a/booki.c +++ b/booki.c @@ -190,7 +190,7 @@ void parse_book(char* current_pos, struct Book* book) { book->author = author; current_pos = new_pos; } else if (ATTR_MATCH(attr, "language")) { - struct es language = parse_string(current_pos, &new_pos); + struct es language = parse_strings(current_pos, &new_pos); book->language = language; current_pos = new_pos; } else if (ATTR_MATCH(attr, "isbn")) { @@ -198,7 +198,7 @@ void parse_book(char* current_pos, struct Book* book) { book->isbn = isbn; current_pos = new_pos; } else if (ATTR_MATCH(attr, "translator")) { - struct es translator = parse_string(current_pos, &new_pos); + struct es translator = parse_strings(current_pos, &new_pos); book->translator = translator; current_pos = new_pos; } else if (ATTR_MATCH(attr, "pages")) { @@ -522,9 +522,8 @@ void open(char* filepath) { } } -void free_book(struct Book book) { - // any string can be a list of strings - struct es* str = book.author.next; +void free_es(struct es* str) { + if (str == NULL) return; struct es* tmp; while (str != NULL) { tmp = str->next; @@ -533,6 +532,13 @@ void free_book(struct Book book) { } } +void free_book(struct Book book) { + // any string can be a list of strings + free_es(book.author.next); + free_es(book.translator.next); + free_es(book.language.next); +} + void search(int argc, char* argv[], char* booki_file) { struct search_opt search_opts = parse_search_options(argc, argv); -- cgit v1.2.3