From 23d31fbb7c6dee44226443c04f556c947f3985c1 Mon Sep 17 00:00:00 2001 From: Alejandro del Castillo Date: Wed, 10 Feb 2016 16:27:26 -0600 Subject: [PATCH] active_list_sort: remove unused function Signed-off-by: Alejandro del Castillo [Jo-Philipp Wich: remove call from opkg_active_list_test] Signed-off-by: Jo-Philipp Wich --- libopkg/active_list.c | 40 ----------------------------------- libopkg/active_list.h | 4 ---- tests/opkg_active_list_test.c | 13 ------------ 3 files changed, 57 deletions(-) diff --git a/libopkg/active_list.c b/libopkg/active_list.c index ceac6e9..a7ce08e 100644 --- a/libopkg/active_list.c +++ b/libopkg/active_list.c @@ -137,43 +137,3 @@ void active_list_head_delete(struct active_list *head) active_list_clear(head); free(head); } - -/* - * Using insert sort. - * Note. the list should not be large, or it will be very inefficient. - * - */ -struct active_list *active_list_sort(struct active_list *head, - int (*compare) (const void *, - const void *)) -{ - struct active_list tmphead; - struct active_list *node, *ptr; - if (!head) - return NULL; - active_list_init(&tmphead); - for (node = active_list_next(head, NULL); node; - node = active_list_next(head, NULL)) { - if (tmphead.node.next == &tmphead.node) { - active_list_move_node(head, &tmphead, node); - } else { - for (ptr = active_list_next(&tmphead, NULL); ptr; - ptr = active_list_next(&tmphead, ptr)) { - if (compare(ptr, node) <= 0) { - break; - } - } - if (!ptr) { - active_list_move_node(head, &tmphead, node); - } else { - active_list_move_node(head, ptr, node); - } - } - node->depended = &tmphead; - } - for (ptr = active_list_prev(&tmphead, NULL); ptr; - ptr = active_list_prev(&tmphead, NULL)) { - active_list_move_node(&tmphead, head, ptr); - } - return head; -} diff --git a/libopkg/active_list.h b/libopkg/active_list.h index 2775680..fae480b 100644 --- a/libopkg/active_list.h +++ b/libopkg/active_list.h @@ -37,10 +37,6 @@ struct active_list *active_list_move_node(struct active_list *old_head, struct active_list *new_head, struct active_list *node); -struct active_list *active_list_sort(struct active_list *head, - int (*compare_fcn_t) (const void *, - const void *)); - struct active_list *active_list_next(struct active_list *head, struct active_list *ptr); diff --git a/tests/opkg_active_list_test.c b/tests/opkg_active_list_test.c index b377d50..8028d0e 100644 --- a/tests/opkg_active_list_test.c +++ b/tests/opkg_active_list_test.c @@ -85,15 +85,6 @@ static void make_list(struct active_list *head) active_test_add(head, O); } -static int active_test_compare(const void *a, const void *b) -{ - struct active_list *first = (struct active_list *)a; - struct active_list *second = (struct active_list *)b; - return memcmp(list_entry(first, struct active_test, list), - list_entry(second, struct active_test, list), - sizeof(struct active_test)); -} - static void show_list(struct active_list *head) { struct active_list *ptr; @@ -126,10 +117,6 @@ int main(void) test = list_entry(ptr, struct active_test, list); printf("%s ", test->str); } - printf("\npos order after sort: "); - active_list_sort(&head, &active_test_compare); - show_list(&head); - printf("after clear: "); active_list_clear(&head); for (ptr = active_list_next(&head, NULL); ptr; -- 2.30.2