diff options
author | JSDurand <mmemmew@gmail.com> | 2022-02-05 17:30:11 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2022-02-05 17:30:11 +0800 |
commit | 510b10b96b546fcc6c6b6be85050305ddd192a41 (patch) | |
tree | 997d6c3f2c0a1ad6e27127d54a94655527e57864 /src/list.c | |
parent | 3fb5430080199a6d92a63f8259fe4a88df9b83ba (diff) |
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.
Diffstat (limited to 'src/list.c')
-rw-r--r-- | src/list.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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)); |