From 6fe77e2f20f045b89ed10c3952f8f088e9bd3d6c Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Wed, 4 Jan 2023 18:22:24 -0800 Subject: fully functional parser (collisions might be a problem) --- src/hash_table.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/hash_table.c') diff --git a/src/hash_table.c b/src/hash_table.c index a6524ac..99508e9 100644 --- a/src/hash_table.c +++ b/src/hash_table.c @@ -2,6 +2,7 @@ #include "./include/ast.h" #include "./include/macros.h" #include +#include #include #include @@ -33,12 +34,14 @@ sl_list_t *init_sl_list() { return l; } +/* TODO: fix segfault bug */ void sl_list_add(sl_list_t *l, char *key, ast_t *value) { sl_node_t *cur = l->head; bool modified = false; if (l->head == NULL) { l->head = init_sl_node(key, value); l->size++; + return; } for (int i = 0; i < l->size - 1; i++) { @@ -49,6 +52,7 @@ void sl_list_add(sl_list_t *l, char *key, ast_t *value) { } cur = cur->next; } + if (strcmp(cur->value->key, key) == 0) { cur->value->value = value; modified = true; -- cgit