diff options
author | Christian Cunningham <cc@localhost> | 2022-02-04 23:55:05 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-02-04 23:55:05 -0700 |
commit | e3eb5a92ae3991cdfbb5a5cf553eac476bc5822f (patch) | |
tree | b6f8b98b8e9b970dc08c218c07b1351b0eaf2944 /src/lib/ll.c | |
parent | 1b14e08247393af5f4e8f2a3c31406ce750ca2f0 (diff) |
Removed old mem
Diffstat (limited to 'src/lib/ll.c')
-rw-r--r-- | src/lib/ll.c | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/lib/ll.c b/src/lib/ll.c deleted file mode 100644 index 4918194..0000000 --- a/src/lib/ll.c +++ /dev/null @@ -1,57 +0,0 @@ -#include <lib/ll.h> -#include <lib/mem.h> - -struct LL* new_ll(void* val) -{ - struct LL* ll = (struct LL*)malloc(sizeof(struct LL)); - ll->prev = ll; - ll->next = ll; - ll->data = val; - return ll; -} - -void push_ll(struct LL* l, void* val) -{ - struct LL* ll = (struct LL*)malloc(sizeof(struct LL)); - l->prev->next = ll; - ll->prev = l->prev; - ll->next = l; - l->prev = ll; - ll->data = val; -} - -void pop_ll(struct LL* l) -{ - if ((l->prev == l->next) && (l->prev == l)) - l->data = 0; - else { - l->prev->next = l->next; - l->next->prev = l->prev; - free(l); - } -} - -void remove_ll(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); -} - -unsigned long length_ll(struct LL* l) -{ - struct LL* t = l; - unsigned long len = 0; - while (1) { - if (t->next == l) { - return len; - } - len++; - t = t->next; - } - return len; -} |