summaryrefslogtreecommitdiff
path: root/lichen.c
diff options
context:
space:
mode:
Diffstat (limited to 'lichen.c')
-rw-r--r--lichen.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/lichen.c b/lichen.c
index f028d92..b0b0684 100644
--- a/lichen.c
+++ b/lichen.c
@@ -79,10 +79,10 @@ void li_free_ll(struct li_ll_t *list, void (*free_data)(void*)) {
void li_ll_append(struct li_ll_t *list, void *data) {
li_llnode_t *n = li_alloc_llnode();
- n->data = data;
if (n == NULL) {
return;
}
+ n->data = data;
if (list->end != NULL) {
list->end->next = n;
list->end = n;
@@ -93,9 +93,25 @@ void li_ll_append(struct li_ll_t *list, void *data) {
list->count += 1;
}
+
+void li_ll_prepend(struct li_ll_t *list, void *data) {
+ li_llnode_t *n = li_alloc_llnode();
+ if (n == NULL) {
+ return;
+ }
+ n->data = data;
+ if (list->head != NULL) {
+ n->next = list->head;
+ list->head = n;
+ } else {
+ list->head = n;
+ list->end = n;
+ }
+ list->count += 1;
+}
+
+
struct li_ll_t * li_copy_list(struct li_ll_t *list) {
list = list;
return NULL;
}
-
-