aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--booki.c16
1 files changed, 11 insertions, 5 deletions
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);