aboutsummaryrefslogtreecommitdiff
path: root/src/ll.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ll.c')
-rw-r--r--src/ll.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/ll.c b/src/ll.c
index fdf86af..8e2d078 100644
--- a/src/ll.c
+++ b/src/ll.c
@@ -70,15 +70,18 @@ void llinsert(Node** head, int value, int index) {
node->next = n;
}
-void llfree(Node* head) {
- Node* n = NULL;
- while (head != NULL) {
- n = head;
- head = head->next;
+void llfree(Node** head) {
+ while (*head != NULL) {
+ Node* n = *head;
+ *head = (*head)->next;
free(n);
}
+ *head = NULL;
}
+// TODO: llfree recursive implementation
+// ...
+
int llrmlast(Node** head) {
Node* n = *head;
Node* cur = NULL;