From f32a7e809e2052fbc38676691043206835e06920 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 30 Dec 2022 09:56:59 -0800 Subject: [PATCH] sparse: remove no longer used doubly linked list implementation --- lib/sparse/LinkedList.c | 66 ----------------------------------------- lib/sparse/LinkedList.h | 19 ------------ 2 files changed, 85 deletions(-) diff --git a/lib/sparse/LinkedList.c b/lib/sparse/LinkedList.c index bf7389dbb..ad1d136dd 100644 --- a/lib/sparse/LinkedList.c +++ b/lib/sparse/LinkedList.c @@ -66,69 +66,3 @@ void SingleLinkedList_print(SingleLinkedList head, void (*linkedlist_print)(void } while (head); } - - -DoubleLinkedList DoubleLinkedList_new(void *data){ - DoubleLinkedList head = gv_alloc(sizeof(struct DoubleLinkedList_struct)); - head->data = data; - return head; -} - -void DoubleLinkedList_delete(DoubleLinkedList head, void (*linklist_deallocator)(void*)){ - DoubleLinkedList next; - - if (!head) return; - do { - next = head->next; - if (head->data) linklist_deallocator(head->data); - free(head); - head = next; - } while (head); - -} - - -DoubleLinkedList DoubleLinkedList_prepend(DoubleLinkedList l, void *data){ - DoubleLinkedList head = DoubleLinkedList_new(data); - if (l){ - head->next = l; - l->prev = head; - } - return head; -} - -void* DoubleLinkedList_get_data(DoubleLinkedList l){ - return l->data; -} - -DoubleLinkedList DoubleLinkedList_get_next(DoubleLinkedList l){ - return l->next; -} - -void DoubleLinkedList_print(DoubleLinkedList head, void (*linkedlist_print)(void*)){ - - if (!head) return; - do { - if (head->data) linkedlist_print(head->data); - head = head->next; - } while (head); - -} - -void DoubleLinkedList_delete_element(DoubleLinkedList l, void (*linklist_deallocator)(void*), DoubleLinkedList *head){ - /* delete an entry in the chain of linked list. If the head changes due to this (if l is the first element in the list), update */ - DoubleLinkedList next, prev; - - if (l){ - next = l->next; - prev = l->prev; - - if (l->data) linklist_deallocator(l->data); - free(l); - l = NULL; - - if (next) next->prev = prev; - if (prev) prev->next = next; - if (!prev) *head = next; - } -} diff --git a/lib/sparse/LinkedList.h b/lib/sparse/LinkedList.h index 0c098d9d0..98371ab77 100644 --- a/lib/sparse/LinkedList.h +++ b/lib/sparse/LinkedList.h @@ -33,25 +33,6 @@ SingleLinkedList SingleLinkedList_get_next(SingleLinkedList l); void SingleLinkedList_print(SingleLinkedList head, void (*linkedlist_print)(void*)); - -typedef struct DoubleLinkedList_struct* DoubleLinkedList; - -struct DoubleLinkedList_struct { - void *data; - DoubleLinkedList next; - DoubleLinkedList prev; -}; - -DoubleLinkedList DoubleLinkedList_new(void *data); -void DoubleLinkedList_delete(DoubleLinkedList head, void (*linklist_deallocator)(void*)); -DoubleLinkedList DoubleLinkedList_prepend(DoubleLinkedList l, void *data); - -void* DoubleLinkedList_get_data(DoubleLinkedList l); - -DoubleLinkedList DoubleLinkedList_get_next(DoubleLinkedList l); - -void DoubleLinkedList_delete_element(DoubleLinkedList l, void (*linklist_deallocator)(void*), DoubleLinkedList *head); - #ifdef __cplusplus } #endif -- 2.40.0