From d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Mon, 11 Mar 2024 21:30:31 -0400 Subject: usermode capable kernel with logging syscall --- lib/linkedlist.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/linkedlist.c (limited to 'lib/linkedlist.c') diff --git a/lib/linkedlist.c b/lib/linkedlist.c new file mode 100644 index 0000000..6cc6403 --- /dev/null +++ b/lib/linkedlist.c @@ -0,0 +1,34 @@ +#include "linkedlist.h" + +void +sll_new(struct SLinkedList *list, size_t obj_size) +{ + list->obj_size = obj_size; + list->count = 0; + list->head = list->tail = NULL; +}; + +void +sll_push(struct SLinkedList *list, void *data) +{ + struct SLLNode *node = (struct SLLNode*)data; + if(list->tail != NULL) { + list->tail->next = node; + } + if(list->head == NULL) + list->head = node; + list->tail = node; + list->count++; +} + +void* +sll_get(struct SLinkedList *list, size_t index) +{ + struct SLLNode *node = list->head; + if(node == NULL) return NULL; + if(index > list->count) return list->tail; + for(size_t i = 0; i < index; i++) { + node = node->next; + } + return node; +} -- cgit v1.2.1