From: Alejandro del Castillo Date: Wed, 10 Feb 2016 22:27:26 +0000 (-0600) Subject: active_list_sort: remove unused function X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=23d31fbb7c6dee44226443c04f556c947f3985c1;p=oweals%2Fopkg-lede.git 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 --- 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;