removes deprecated ucx_list_append_once() and ucx_list_prepend_once()

Thu, 17 May 2018 11:13:02 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 17 May 2018 11:13:02 +0200
changeset 323
b8c49e7a1dba
parent 322
fd21d1840dff
child 324
343bff4cc0b5

removes deprecated ucx_list_append_once() and ucx_list_prepend_once()

src/list.c file | annotate | diff | comparison | revisions
src/ucx/list.h file | annotate | diff | comparison | revisions
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
--- 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);
 }
--- 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.
- * 
- * <b>Note:</b> 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.
- * 
- * <b>Deprecation notice:</b> 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 <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 <code>list</code>, if it is not <code>NULL</code> 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.
- * 
- * <b>Note:</b> 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.
- * 
- * <b>Deprecation notice:</b> 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 <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 <code>list</code>, if it is not <code>NULL</code> 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.
- * 
- * <b>Note:</b> 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.
- * 
- * <b>Deprecation notice:</b> 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 <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.
- * 
- * <b>Note:</b> 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.
- * 
- * <b>Deprecation notice:</b> 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 <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);
 
 /**
  * Inserts an element at the beginning of the list.
--- 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!";
--- 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);
--- 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);

mercurial