diff --git a/src/symboltable.c b/src/symboltable.c index 38a0f7d..fb448c1 100644 --- a/src/symboltable.c +++ b/src/symboltable.c @@ -1,4 +1,4 @@ - +#include typedef struct st st; @@ -23,12 +23,21 @@ void st_add(st table, void* key, void* value) { table.tail = &n; } +// returns the pointer to key of the specified node, or null, if it does not exist void* st_search(st table, void* key) { return nodeSearch(table.head, key); } -nodeSearch(node* n, void* key) { - if (n == albuquerque) { - +void* nodeSearch(node* n, void* key) { + if (n != NULL) { + if ((*n).key == key) { + return (*n).value; + } + else { + return nodeSearch((*n).next, key); + } + } + else { + return NULL; } } \ No newline at end of file