aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ll.c
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2021-12-30 20:50:44 -0800
committerChristian Cunningham <cc@localhost>2021-12-30 20:50:44 -0800
commite15d41a5619c41f3440369e625d6d96921718221 (patch)
tree1291a6f4cb964d7143ab63626bc03ebefaff484b /src/lib/ll.c
parent104c6fdd6b217b06183df7007882afa9183688bb (diff)
Added Data Structures
Added basic scheduling TODO: Preserve registers for context switch
Diffstat (limited to 'src/lib/ll.c')
-rw-r--r--src/lib/ll.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lib/ll.c b/src/lib/ll.c
new file mode 100644
index 0000000..6d96f45
--- /dev/null
+++ b/src/lib/ll.c
@@ -0,0 +1,32 @@
+#include "../lib/ll.h"
+#include "../lib/mem.h"
+
+struct LL* new(void* val)
+{
+ struct LL* ll = (struct LL*)malloc(sizeof(struct LL));
+ ll->prev = ll;
+ ll->next = ll;
+ ll->data = val;
+ return ll;
+}
+
+void push(struct LL* l, void* val)
+{
+ struct LL* ll = (struct LL*)malloc(sizeof(struct LL));
+ ll->prev = l->prev;
+ ll->next = l;
+ ll->prev->next = ll;
+ l->prev = ll;
+ ll->data = val;
+}
+
+void remove(struct LL* l, unsigned long idx)
+{
+ struct LL* t = l;
+ for(unsigned long i = 0; i < idx; i++) {
+ t = t->next;
+ }
+ t->prev->next = t->next;
+ t->next->prev = t->prev;
+ free(t);
+}