linked-list: Remove unused clone_function() method
This commit is contained in:
@@ -440,21 +440,6 @@ METHOD(linked_list_t, clone_offset, linked_list_t*,
|
|||||||
return clone;
|
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,
|
METHOD(linked_list_t, destroy, void,
|
||||||
private_linked_list_t *this)
|
private_linked_list_t *this)
|
||||||
{
|
{
|
||||||
@@ -526,7 +511,6 @@ linked_list_t *linked_list_create()
|
|||||||
.invoke_offset = (void*)_invoke_offset,
|
.invoke_offset = (void*)_invoke_offset,
|
||||||
.invoke_function = (void*)_invoke_function,
|
.invoke_function = (void*)_invoke_function,
|
||||||
.clone_offset = _clone_offset,
|
.clone_offset = _clone_offset,
|
||||||
.clone_function = _clone_function,
|
|
||||||
.destroy = _destroy,
|
.destroy = _destroy,
|
||||||
.destroy_offset = _destroy_offset,
|
.destroy_offset = _destroy_offset,
|
||||||
.destroy_function = _destroy_function,
|
.destroy_function = _destroy_function,
|
||||||
|
|||||||
@@ -226,14 +226,6 @@ struct linked_list_t {
|
|||||||
*/
|
*/
|
||||||
linked_list_t *(*clone_offset) (linked_list_t *this, size_t offset);
|
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.
|
* Destroys a linked_list object.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -303,14 +303,9 @@ struct clone_t {
|
|||||||
void *(*clone)(clone_t *item);
|
void *(*clone)(clone_t *item);
|
||||||
};
|
};
|
||||||
|
|
||||||
static void *clone(void *item)
|
static void *clone(clone_t *item)
|
||||||
{
|
{
|
||||||
return item;
|
return item->val;
|
||||||
}
|
|
||||||
|
|
||||||
static void *clone_offset(clone_t *item)
|
|
||||||
{
|
|
||||||
return clone(item->val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_clone(linked_list_t *list)
|
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);
|
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)
|
START_TEST(test_clone_offset)
|
||||||
{
|
{
|
||||||
linked_list_t *other;
|
linked_list_t *other;
|
||||||
clone_t items[] = {
|
clone_t items[] = {
|
||||||
{ .val = (void*)1, .clone = clone_offset, },
|
{ .val = (void*)1, .clone = clone, },
|
||||||
{ .val = (void*)2, .clone = clone_offset, },
|
{ .val = (void*)2, .clone = clone, },
|
||||||
{ .val = (void*)3, .clone = clone_offset, },
|
{ .val = (void*)3, .clone = clone, },
|
||||||
{ .val = (void*)4, .clone = clone_offset, },
|
{ .val = (void*)4, .clone = clone, },
|
||||||
{ .val = (void*)5, .clone = clone_offset, },
|
{ .val = (void*)5, .clone = clone, },
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -400,7 +379,6 @@ Suite *linked_list_suite_create()
|
|||||||
|
|
||||||
tc = tcase_create("clone");
|
tc = tcase_create("clone");
|
||||||
tcase_add_checked_fixture(tc, setup_list, teardown_list);
|
tcase_add_checked_fixture(tc, setup_list, teardown_list);
|
||||||
tcase_add_test(tc, test_clone_function);
|
|
||||||
tcase_add_test(tc, test_clone_offset);
|
tcase_add_test(tc, test_clone_offset);
|
||||||
suite_add_tcase(s, tc);
|
suite_add_tcase(s, tc);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user