From 510b10b96b546fcc6c6b6be85050305ddd192a41 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 5 Feb 2022 17:30:11 +0800 Subject: replace some hash table usage by tuples Previously I used hash tables, which consume too much memory. Now the critical parts are replaced by a new hand-written library called "tuple.h". Now we can easily parse larger inputs. I haven't tested its limits, though. --- src/list.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/list.c') diff --git a/src/list.c b/src/list.c index 1b9f4d4..05d760c 100644 --- a/src/list.c +++ b/src/list.c @@ -157,7 +157,7 @@ H_ATTR NUM list_length(const List * const restrict ls) { - return ls->len; + return (ls == NULL) ? 0 : ls->len; } BOOL @@ -231,7 +231,7 @@ List * array_to_list(void **array, NUM size) { List *ls = NULL; - + SAFE_MALLOC(List, ls, 1, return NULL;); ls->array = array; @@ -243,6 +243,8 @@ array_to_list(void **array, NUM size) void destroy_list(List *ls, BOOL all_free_p) { + if (ls == NULL) return; + if (all_free_p == 1) for (NUM i = 0; i < ls->len; i++) free(*(ls->array+i)); -- cgit v1.2.3-18-g5258