modified: src/llist.c

modified:   src/llist.h
This commit is contained in:
simon committed 2024-12-11 17:27:25 +01:00
1 parent a88262bb28
commit 9014bd0517
2 files changed
+8 -5

No files matched your search

+7 -5
View File
@@ -15,6 +15,7 @@ llist *llistNew(void *data, int (*cmpFN)(void *a, void *b)) {
r->data = data;
r->prev = NULL;
r->next = NULL;
r->tail = r;
}
return r;
}
@@ -22,11 +23,11 @@ llist *llistNew(void *data, int (*cmpFN)(void *a, void *b)) {
/*return last node of linked list;
*/
llist *llistTail(llist *head) {
llist *tail = head;
while (tail->next != NULL) {
tail = tail->next;
}
return tail;
// llist *tail = head;
// while (tail->next != NULL) {
// tail = tail->next;
// }
return head->tail;
}
/* creates new node from data and appends it to tail
@@ -40,6 +41,7 @@ llist *llistAppend(llist *head, void *data) {
new->next = NULL;
new->prev = tail;
tail->next = new;
head->tail = new;
}
return new;
}