linked-list: Remove unused clone_function() method
authorTobias Brunner <tobias@strongswan.org>
Tue, 16 Jul 2013 10:07:00 +0000 (12:07 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 17 Jul 2013 15:42:53 +0000 (17:42 +0200)
src/libstrongswan/collections/linked_list.c
src/libstrongswan/collections/linked_list.h
src/libstrongswan/tests/test_linked_list.c

index 4feb66f..274ad8e 100644 (file)
@@ -440,21 +440,6 @@ METHOD(linked_list_t, clone_offset, linked_list_t*,
        return clone;
 }
 
-METHOD(linked_list_t, clone_function, linked_list_t*,
-       private_linked_list_t *this, void* (*fn)(void*))
-{
-       element_t *current = this->first;
-       linked_list_t *clone;
-
-       clone = linked_list_create();
-       while (current)
-       {
-               clone->insert_last(clone, fn(current->value));
-               current = current->next;
-       }
-       return clone;
-}
-
 METHOD(linked_list_t, destroy, void,
        private_linked_list_t *this)
 {
@@ -526,7 +511,6 @@ linked_list_t *linked_list_create()
                        .invoke_offset = (void*)_invoke_offset,
                        .invoke_function = (void*)_invoke_function,
                        .clone_offset = _clone_offset,
-                       .clone_function = _clone_function,
                        .destroy = _destroy,
                        .destroy_offset = _destroy_offset,
                        .destroy_function = _destroy_function,
index 9feced0..bc77765 100644 (file)
@@ -227,14 +227,6 @@ struct linked_list_t {
        linked_list_t *(*clone_offset) (linked_list_t *this, size_t offset);
 
        /**
-        * Clones a list and its objects using a given function.
-        *
-        * @param function      function that clones an object
-        * @return                      cloned list
-        */
-       linked_list_t *(*clone_function) (linked_list_t *this, void*(*)(void*));
-
-       /**
         * Destroys a linked_list object.
         */
        void (*destroy) (linked_list_t *this);
index aeee48f..9e85c58 100644 (file)
@@ -303,14 +303,9 @@ struct clone_t {
        void *(*clone)(clone_t *item);
 };
 
-static void *clone(void *item)
+static void *clone(clone_t *item)
 {
-       return item;
-}
-
-static void *clone_offset(clone_t *item)
-{
-       return clone(item->val);
+       return item->val;
 }
 
 static void test_clone(linked_list_t *list)
@@ -327,31 +322,15 @@ static void test_clone(linked_list_t *list)
        ck_assert_int_eq(round, 6);
 }
 
-START_TEST(test_clone_function)
-{
-       linked_list_t *other;
-
-       list->insert_last(list, (void*)1);
-       list->insert_last(list, (void*)2);
-       list->insert_last(list, (void*)3);
-       list->insert_last(list, (void*)4);
-       list->insert_last(list, (void*)5);
-
-       other = list->clone_function(list, clone);
-       test_clone(other);
-       other->destroy(other);
-}
-END_TEST
-
 START_TEST(test_clone_offset)
 {
        linked_list_t *other;
        clone_t items[] = {
-               { .val = (void*)1, .clone = clone_offset, },
-               { .val = (void*)2, .clone = clone_offset, },
-               { .val = (void*)3, .clone = clone_offset, },
-               { .val = (void*)4, .clone = clone_offset, },
-               { .val = (void*)5, .clone = clone_offset, },
+               { .val = (void*)1, .clone = clone, },
+               { .val = (void*)2, .clone = clone, },
+               { .val = (void*)3, .clone = clone, },
+               { .val = (void*)4, .clone = clone, },
+               { .val = (void*)5, .clone = clone, },
        };
        int i;
 
@@ -400,7 +379,6 @@ Suite *linked_list_suite_create()
 
        tc = tcase_create("clone");
        tcase_add_checked_fixture(tc, setup_list, teardown_list);
-       tcase_add_test(tc, test_clone_function);
        tcase_add_test(tc, test_clone_offset);
        suite_add_tcase(s, tc);