Browse Source

active_list_sort: remove unused function

Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
[Jo-Philipp Wich: remove call from opkg_active_list_test]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Alejandro del Castillo 8 years ago
parent
commit
23d31fbb7c
3 changed files with 0 additions and 57 deletions
  1. 0 40
      libopkg/active_list.c
  2. 0 4
      libopkg/active_list.h
  3. 0 13
      tests/opkg_active_list_test.c

+ 0 - 40
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;
-}

+ 0 - 4
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);
 

+ 0 - 13
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;