summaryrefslogtreecommitdiff
path: root/src/ll.c
diff options
context:
space:
mode:
author@syxhe <https://t.me/syxhe>2024-06-18 18:51:36 -0500
committer@syxhe <https://t.me/syxhe>2024-06-18 18:51:36 -0500
commitc92b4f7cf884cde740d2c5986d6f88be7dcafcc2 (patch)
treea586ac66e2c8de61b6e412e53949e28ccbbc7271 /src/ll.c
parent1e9915d2ce9baa31506a8c04929d6e44a29f106b (diff)
Almost make scanning folders work
Diffstat (limited to 'src/ll.c')
-rw-r--r--src/ll.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/ll.c b/src/ll.c
new file mode 100644
index 0000000..1a0426b
--- /dev/null
+++ b/src/ll.c
@@ -0,0 +1,53 @@
1#include "ll.h"
2
3#include <stdlib.h>
4#include <error.h>
5#include <errno.h>
6
7#include <stdio.h>
8
9// Initialize an empty nodelist object
10struct nodelist* nodelist_init(struct nodelist *start) {
11 if(start == NULL) {
12 start = calloc(1, sizeof(struct nodelist));
13 if(start == NULL) {
14 error(0, errno, "Could not allocate space for empty node list object");
15 return NULL;
16 }
17 }
18
19 start->fullpath = NULL;
20 start->next = NULL;
21 start->type = NODELIST_TYPE__UNDEF;
22
23 return start;
24}
25
26struct nodelist* nodelist_prepend(struct nodelist *new, struct nodelist *list) {
27 new->next = list;
28 return new;
29}
30
31struct nodelist* nodelist_append(struct nodelist *list, struct nodelist *append) {
32 struct nodelist *p = NULL, *prev = NULL;
33 for(p = list; p != NULL; p = p->next)
34 prev = p;
35
36 // If the pointer p is null, prev will never be set, so just error out
37 if(prev == NULL)
38 return NULL;
39
40 prev->next = append;
41
42 return list;
43}
44
45int nodelist_delete(struct nodelist *list) {
46 struct nodelist *p, *next;
47 for(p = list; p != NULL; p = next) {
48 next = p->next;
49 free(p);
50 }
51
52 return 0;
53} \ No newline at end of file