Fri, 18 Nov 2016 15:33:58 +0100
removes ucx_list_prepend_once() - this was a big mistake....
test/list_tests.c | file | annotate | diff | comparison | revisions | |
test/list_tests.h | file | annotate | diff | comparison | revisions | |
test/main.c | file | annotate | diff | comparison | revisions | |
ucx/list.c | file | annotate | diff | comparison | revisions | |
ucx/list.h | file | annotate | diff | comparison | revisions |
--- a/test/list_tests.c Fri Nov 18 15:17:04 2016 +0100 +++ b/test/list_tests.c Fri Nov 18 15:33:58 2016 +0100 @@ -89,28 +89,6 @@ ucx_list_free(list); } -UCX_TEST(test_ucx_list_prepend_once) { - UcxList *list, *last, *first; - list = last = ucx_list_prepend_once(NULL, (void*)" World!", - ucx_strcmp, NULL); - UCX_TEST_BEGIN - - list = ucx_list_prepend_once(list, (void*)"Hello", ucx_strcmp, NULL); - first = ucx_list_prepend_once(list, (void*)"Hello", ucx_strcmp, NULL); - - UCX_TEST_ASSERT(list == first, "'Hello' was not prepended _once_"); - UCX_TEST_ASSERT(first == last->prev, "does not return first element"); - UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0, - "failed"); - UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0, - "failed"); - UCX_TEST_ASSERT(list->next->next == NULL, "right not terminated"); - UCX_TEST_ASSERT(list->prev == NULL, "left not terminated"); - - UCX_TEST_END - ucx_list_free(list); -} - UCX_TEST(test_ucx_list_equals) { const char *hello = "Hello"; const char *world = " World!";
--- a/test/list_tests.h Fri Nov 18 15:17:04 2016 +0100 +++ b/test/list_tests.h Fri Nov 18 15:33:58 2016 +0100 @@ -46,7 +46,6 @@ UCX_TEST(test_ucx_list_append); UCX_TEST(test_ucx_list_prepend); UCX_TEST(test_ucx_list_append_once); -UCX_TEST(test_ucx_list_prepend_once); UCX_TEST(test_ucx_list_equals); UCX_TEST(test_ucx_list_concat); UCX_TEST(test_ucx_list_size);
--- a/test/main.c Fri Nov 18 15:17:04 2016 +0100 +++ b/test/main.c Fri Nov 18 15:33:58 2016 +0100 @@ -138,7 +138,6 @@ ucx_test_register(suite, test_ucx_list_append); ucx_test_register(suite, test_ucx_list_prepend); ucx_test_register(suite, test_ucx_list_append_once); - ucx_test_register(suite, test_ucx_list_prepend_once); ucx_test_register(suite, test_ucx_list_equals); ucx_test_register(suite, test_ucx_list_concat); ucx_test_register(suite, test_ucx_list_size);
--- a/ucx/list.c Fri Nov 18 15:17:04 2016 +0100 +++ b/ucx/list.c Fri Nov 18 15:33:58 2016 +0100 @@ -159,40 +159,6 @@ return nl; } -UcxList *ucx_list_prepend_once(UcxList *l, void *data, - cmp_func cmpfnc, void* cmpdata) { - return ucx_list_prepend_once_a(ucx_default_allocator(), l, - data, cmpfnc, cmpdata); -} - -UcxList *ucx_list_prepend_once_a(UcxAllocator *alloc, UcxList *l, void *data, - cmp_func cmpfnc, void *cmpdata) { - - if (l) { - int found = 0; - UcxList *first; - { - UcxList *e = l; - while (e) { - found |= (cmpfnc(e->data, data, cmpdata) == 0); - first = e; - e = e->prev; - } - } - - if (found) { - return first; - } else { - UcxList *nl = ucx_list_append_a(alloc, NULL, data); - nl->next = first; - first->prev = nl; - return nl; - } - } else { - return ucx_list_append_a(alloc, NULL, data); - } -} - UcxList *ucx_list_concat(UcxList *l1, UcxList *l2) { if (l1) { UcxList *last = ucx_list_last(l1);
--- a/ucx/list.h Fri Nov 18 15:17:04 2016 +0100 +++ b/ucx/list.h Fri Nov 18 15:33:58 2016 +0100 @@ -276,37 +276,6 @@ UcxList *ucx_list_prepend_a(UcxAllocator *allocator, UcxList *list, void *data); /** - * Inserts an element at the beginning of the list, if it is not present - * in the list. - * - * @param list the list where to insert the data or <code>NULL</code> to create - * a new list - * @param data the data to insert - * @param cmpfnc the compare function - * @param cmpdata additional data for the compare function - * @return a pointer to the new list head - * @see ucx_list_prepend() - */ -UcxList *ucx_list_prepend_once(UcxList *list, void *data, - cmp_func cmpfnc, void *cmpdata); - -/** - * Inserts an element at the beginning of the list, if it is not present in - * the list, using a UcxAllocator. - * - * @param allocator the allocator to use - * @param list the list where to insert the data or <code>NULL</code> to create - * a new list - * @param data the data to insert - * @param cmpfnc the compare function - * @param cmpdata additional data for the compare function - * @return a pointer to the new list head - * @see ucx_list_prepend_a() - */ -UcxList *ucx_list_prepend_once_a(UcxAllocator *allocator, - UcxList *list, void *data, cmp_func cmpfnc, void *cmpdata); - -/** * Concatenates two lists. * * Either of the two arguments may be <code>NULL</code>.