First commit, fixed appending, create, destroy and get, all working fine

This commit is contained in:
2026-02-12 10:47:46 -06:00
commit 7611096e13
6 changed files with 293 additions and 0 deletions

26
include/linkedlist.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <stdlib.h>
typedef struct LinkedList LinkedList;
typedef enum {
LLIST_OK = 0,
LLIST_ALLOC,
LLIST_NULL,
LLIST_NULL_ARG,
LLIST_OUT_OF_BOUNDS,
LLIST_INVALID_SIZE,
} LinkedListErr;
LinkedListErr linkedlist_create(LinkedList **out, size_t elem_size);
LinkedListErr linkedlist_destroy(LinkedList *ll);
LinkedListErr linkedlist_append(LinkedList *ll, void *data);
LinkedListErr linkedlist_delete(LinkedList *ll, size_t index);
LinkedListErr linkedlist_pop(LinkedList *ll, size_t index, void *out);
LinkedListErr linkedlist_insert(LinkedList *ll, size_t index, void *out);
LinkedListErr linkedlist_get(const LinkedList *ll, size_t index, void *out);
#endif /* ifndef LINKEDLIST_H */