# HG changeset patch # User Mike Becker # Date 1526548382 -7200 # Node ID b8c49e7a1dba4d1f20643ee932fb473eb8872c9a # Parent fd21d1840dff7a0171e6c3c83a951a2e4b5e1db2 removes deprecated ucx_list_append_once() and ucx_list_prepend_once() diff -r fd21d1840dff -r b8c49e7a1dba src/list.c --- a/src/list.c Wed May 16 19:33:31 2018 +0200 +++ b/src/list.c Thu May 17 11:13:02 2018 +0200 @@ -107,74 +107,6 @@ } } -UcxList *ucx_list_append_once(UcxList *l, void *data, - cmp_func cmpfnc, void *cmpdata) { - return ucx_list_append_once_a(ucx_default_allocator(), l, - data, cmpfnc, cmpdata); -} - -UcxList *ucx_list_append_once_a(UcxAllocator *alloc, UcxList *l, void *data, - cmp_func cmpfnc, void *cmpdata) { - - UcxList *last = NULL; - { - UcxList *e = l; - while (e) { - if (cmpfnc(e->data, data, cmpdata) == 0) { - return l; - } - last = e; - e = e->next; - } - } - - UcxList *nl = ucx_list_append_a(alloc, NULL, data); - if (!nl) { - return NULL; - } - - if (last == NULL) { - return nl; - } else { - nl->prev = last; - last->next = nl; - return l; - } -} - -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) { - - UcxList* first = ucx_list_first(l); - { - UcxList *e = first; - while (e) { - if (cmpfnc(e->data, data, cmpdata) == 0) { - return l; - } - e = e->next; - } - } - - UcxList *nl = ucx_list_append_a(alloc, NULL, data); - if (!nl) { - return NULL; - } - - if (first) { - nl->next = first; - first->prev = nl; - } - - return nl; -} - UcxList *ucx_list_prepend(UcxList *l, void *data) { return ucx_list_prepend_a(ucx_default_allocator(), l, data); } diff -r fd21d1840dff -r b8c49e7a1dba src/ucx/list.h --- a/src/ucx/list.h Wed May 16 19:33:31 2018 +0200 +++ b/src/ucx/list.h Thu May 17 11:13:02 2018 +0200 @@ -212,96 +212,6 @@ */ UcxList *ucx_list_append_a(UcxAllocator *allocator, UcxList *list, void *data); -/** - * Inserts an element at the end of the list, if it is not present in the list. - * - * Note: You should not try to store a freshly allocated object. Since - * it might be a duplicate, the memory allocated for that copy would be leaking - * afterwards. - * - * Deprecation notice: This function is considered to do more harm than - * it adds usefulness and is going to be removed in a future UCX release. - * - * @param list the list where to append the data, or NULL 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 list, if it is not NULL or a pointer to - * the newly created list otherwise - * @see ucx_list_append() - */ -UcxList *ucx_list_append_once(UcxList *list, void *data, - cmp_func cmpfnc, void *cmpdata); - -/** - * Inserts an element at the end of the list, if it is not present in the list, - * using a UcxAllocator. - * - * Note: You should not try to store a freshly allocated object. Since - * it might be a duplicate, the memory allocated for that copy would be leaking - * afterwards. - * - * Deprecation notice: This function is considered to do more harm than - * it adds usefulness and is going to be removed in a future UCX release. - * - * @param allocator the allocator to use - * @param list the list where to append the data, or NULL 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 list, if it is not NULL or a pointer to - * the newly created list otherwise - * @see ucx_list_append_a() - */ -UcxList *ucx_list_append_once_a(UcxAllocator *allocator, - 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. - * - * Note: You should not try to store a freshly allocated object. Since - * it might be a duplicate, the memory allocated for that copy would be leaking - * afterwards. - * - * Deprecation notice: This function is considered to do more harm than - * it adds usefulness and is going to be removed in a future UCX release. - * - * @param list the list where to prepend the data, or NULL 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. - * - * Note: You should not try to store a freshly allocated object. Since - * it might be a duplicate, the memory allocated for that copy would be leaking - * afterwards. - * - * Deprecation notice: This function is considered to do more harm than - * it adds usefulness and is going to be removed in a future UCX release. - * - * @param allocator the allocator to use - * @param list the list where to prepend the data, or NULL 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); /** * Inserts an element at the beginning of the list. diff -r fd21d1840dff -r b8c49e7a1dba test/list_tests.c --- a/test/list_tests.c Wed May 16 19:33:31 2018 +0200 +++ b/test/list_tests.c Thu May 17 11:13:02 2018 +0200 @@ -68,27 +68,6 @@ ucx_list_free(list); } -UCX_TEST(test_ucx_list_append_once) { - UcxList *list, *first; - list = first = ucx_list_append_once(NULL, (void*)"Hello", ucx_cmp_str, NULL); - UCX_TEST_BEGIN - - UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0, - "failed"); - - list = ucx_list_append_once(list, (void*)"Hello", ucx_cmp_str, NULL); - list = ucx_list_append_once(list, (void*)" World!", ucx_cmp_str, NULL); - - UCX_TEST_ASSERT(list == first, "does not return first element"); - UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0, - "'Hello' was not inserted _once_"); - UCX_TEST_ASSERT(list->next->prev == list, "failed"); - UCX_TEST_ASSERT(list->next->next == NULL, "right not terminated"); - UCX_TEST_END - - ucx_list_free(list); -} - UCX_TEST(test_ucx_list_equals) { const char *hello = "Hello"; const char *world = " World!"; diff -r fd21d1840dff -r b8c49e7a1dba test/list_tests.h --- a/test/list_tests.h Wed May 16 19:33:31 2018 +0200 +++ b/test/list_tests.h Thu May 17 11:13:02 2018 +0200 @@ -43,7 +43,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_equals); UCX_TEST(test_ucx_list_concat); UCX_TEST(test_ucx_list_size); diff -r fd21d1840dff -r b8c49e7a1dba test/main.c --- a/test/main.c Wed May 16 19:33:31 2018 +0200 +++ b/test/main.c Thu May 17 11:13:02 2018 +0200 @@ -144,7 +144,6 @@ /* UcxList Tests */ 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_equals); ucx_test_register(suite, test_ucx_list_concat); ucx_test_register(suite, test_ucx_list_size);