diff options
| author | Ben Winston | 2024-05-28 21:29:25 -0400 |
|---|---|---|
| committer | Ben Winston | 2024-05-28 21:29:25 -0400 |
| commit | 17420609eaf0c3c708248a3a7fb4a89aa12a2c1a (patch) | |
| tree | b8a7285c781fd9742b7def181969f30a125ebf38 | |
| parent | 9e76cc03e35e623556c6388006be755dde467555 (diff) | |
support lists of translators and languages
| -rw-r--r-- | booki.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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); |
