diff options
author | Preston Pan <preston@nullring.xyz> | 2023-01-04 18:22:24 -0800 |
---|---|---|
committer | Preston Pan <preston@nullring.xyz> | 2023-01-04 18:22:24 -0800 |
commit | 6fe77e2f20f045b89ed10c3952f8f088e9bd3d6c (patch) | |
tree | 37abb7d1b129a0a46bbff940aa1b728d4d4f0dbd /src/hash_table.c | |
parent | f1e455d2fa84067edda695cbba5ddb9e5b77235e (diff) |
fully functional parser (collisions might be a problem)
Diffstat (limited to 'src/hash_table.c')
-rw-r--r-- | src/hash_table.c | 4 |
1 files changed, 4 insertions, 0 deletions
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 <stdbool.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -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; |