Merge branch 'Assembler-G' into 'assembler'

Assembler g

See merge request lab2324_summer/armv8_43!1
This commit is contained in:
Niedringhaus, George 2024-06-05 18:42:57 +00:00
commit 4e21ac3220
2 changed files with 45 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv) {
return EXIT_SUCCESS;
}

43
src/symboltable.c Normal file
View File

@ -0,0 +1,43 @@
#include <stdio.h>
typedef struct st st;
typedef struct {
const void* key;
void* value;
node* prev;
node* next;
} node;
struct st {
node* head;
node* tail;
};
// add new node to the end
void st_add(st table, void* key, void* value) {
node n = {key, value, table.tail};
(*(table.tail)).next = &n;
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);
}
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;
}
}