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
     1.1 --- a/src/list.c	Wed May 16 19:33:31 2018 +0200
     1.2 +++ b/src/list.c	Thu May 17 11:13:02 2018 +0200
     1.3 @@ -107,74 +107,6 @@
     1.4      }
     1.5  }
     1.6  
     1.7 -UcxList *ucx_list_append_once(UcxList *l, void *data,
     1.8 -        cmp_func cmpfnc, void *cmpdata) {
     1.9 -    return ucx_list_append_once_a(ucx_default_allocator(), l,
    1.10 -            data, cmpfnc, cmpdata);
    1.11 -}
    1.12 -
    1.13 -UcxList *ucx_list_append_once_a(UcxAllocator *alloc, UcxList *l, void *data,
    1.14 -        cmp_func cmpfnc, void *cmpdata) {
    1.15 -
    1.16 -    UcxList *last = NULL;
    1.17 -    {
    1.18 -        UcxList *e = l;
    1.19 -        while (e) {
    1.20 -            if (cmpfnc(e->data, data, cmpdata) == 0) {
    1.21 -                return l;
    1.22 -            }
    1.23 -            last = e;
    1.24 -            e = e->next;
    1.25 -        }
    1.26 -    }
    1.27 -    
    1.28 -    UcxList *nl = ucx_list_append_a(alloc, NULL, data);
    1.29 -    if (!nl) {
    1.30 -        return NULL;
    1.31 -    }
    1.32 -
    1.33 -    if (last == NULL) {
    1.34 -        return nl;
    1.35 -    } else {
    1.36 -        nl->prev = last;
    1.37 -        last->next = nl;
    1.38 -        return l;
    1.39 -    }
    1.40 -}
    1.41 -
    1.42 -UcxList *ucx_list_prepend_once(UcxList *l, void *data,
    1.43 -        cmp_func cmpfnc, void *cmpdata) {
    1.44 -    return ucx_list_prepend_once_a(ucx_default_allocator(), l,
    1.45 -            data, cmpfnc, cmpdata);
    1.46 -}
    1.47 -
    1.48 -UcxList *ucx_list_prepend_once_a(UcxAllocator *alloc, UcxList *l, void *data,
    1.49 -        cmp_func cmpfnc, void *cmpdata) {
    1.50 -
    1.51 -    UcxList* first = ucx_list_first(l);
    1.52 -    {
    1.53 -        UcxList *e = first;
    1.54 -        while (e) {
    1.55 -            if (cmpfnc(e->data, data, cmpdata) == 0) {
    1.56 -                return l;
    1.57 -            }
    1.58 -            e = e->next;
    1.59 -        }
    1.60 -    }
    1.61 -    
    1.62 -    UcxList *nl = ucx_list_append_a(alloc, NULL, data);
    1.63 -    if (!nl) {
    1.64 -        return NULL;
    1.65 -    }
    1.66 -
    1.67 -    if (first) {
    1.68 -        nl->next = first;
    1.69 -        first->prev = nl;
    1.70 -    }
    1.71 -    
    1.72 -    return nl;
    1.73 -}
    1.74 -
    1.75  UcxList *ucx_list_prepend(UcxList *l, void *data) {
    1.76      return ucx_list_prepend_a(ucx_default_allocator(), l, data);
    1.77  }
     2.1 --- a/src/ucx/list.h	Wed May 16 19:33:31 2018 +0200
     2.2 +++ b/src/ucx/list.h	Thu May 17 11:13:02 2018 +0200
     2.3 @@ -212,96 +212,6 @@
     2.4   */
     2.5  UcxList *ucx_list_append_a(UcxAllocator *allocator, UcxList *list, void *data);
     2.6  
     2.7 -/**
     2.8 - * Inserts an element at the end of the list, if it is not present in the list.
     2.9 - * 
    2.10 - * <b>Note:</b> You should not try to store a freshly allocated object. Since
    2.11 - * it might be a duplicate, the memory allocated for that copy would be leaking
    2.12 - * afterwards.
    2.13 - * 
    2.14 - * <b>Deprecation notice:</b> This function is considered to do more harm than
    2.15 - * it adds usefulness and is going to be removed in a future UCX release.
    2.16 - * 
    2.17 - * @param list the list where to append the data, or <code>NULL</code> to
    2.18 - * create a new list
    2.19 - * @param data the data to insert
    2.20 - * @param cmpfnc the compare function
    2.21 - * @param cmpdata additional data for the compare function
    2.22 - * @return <code>list</code>, if it is not <code>NULL</code> or a pointer to
    2.23 - * the newly created list otherwise
    2.24 - * @see ucx_list_append()
    2.25 - */
    2.26 -UcxList *ucx_list_append_once(UcxList *list, void *data,
    2.27 -        cmp_func cmpfnc, void *cmpdata);
    2.28 -
    2.29 -/**
    2.30 - * Inserts an element at the end of the list, if it is not present in the list,
    2.31 - * using a UcxAllocator.
    2.32 - * 
    2.33 - * <b>Note:</b> You should not try to store a freshly allocated object. Since
    2.34 - * it might be a duplicate, the memory allocated for that copy would be leaking
    2.35 - * afterwards.
    2.36 - * 
    2.37 - * <b>Deprecation notice:</b> This function is considered to do more harm than
    2.38 - * it adds usefulness and is going to be removed in a future UCX release.
    2.39 - * 
    2.40 - * @param allocator the allocator to use
    2.41 - * @param list the list where to append the data, or <code>NULL</code> to
    2.42 - * create a new list
    2.43 - * @param data the data to insert
    2.44 - * @param cmpfnc the compare function
    2.45 - * @param cmpdata additional data for the compare function
    2.46 - * @return <code>list</code>, if it is not <code>NULL</code> or a pointer to
    2.47 - * the newly created list otherwise
    2.48 - * @see ucx_list_append_a()
    2.49 - */
    2.50 -UcxList *ucx_list_append_once_a(UcxAllocator *allocator,
    2.51 -        UcxList *list, void *data, cmp_func cmpfnc, void *cmpdata);
    2.52 -
    2.53 -/**
    2.54 - * Inserts an element at the beginning of the list, if it is not present
    2.55 - * in the list.
    2.56 - * 
    2.57 - * <b>Note:</b> You should not try to store a freshly allocated object. Since
    2.58 - * it might be a duplicate, the memory allocated for that copy would be leaking
    2.59 - * afterwards.
    2.60 - * 
    2.61 - * <b>Deprecation notice:</b> This function is considered to do more harm than
    2.62 - * it adds usefulness and is going to be removed in a future UCX release.
    2.63 - * 
    2.64 - * @param list the list where to prepend the data, or <code>NULL</code> to
    2.65 - * create a new list
    2.66 - * @param data the data to insert
    2.67 - * @param cmpfnc the compare function
    2.68 - * @param cmpdata additional data for the compare function
    2.69 - * @return a pointer to the new list head
    2.70 - * @see ucx_list_prepend()
    2.71 - */
    2.72 -UcxList *ucx_list_prepend_once(UcxList *list, void *data,
    2.73 -        cmp_func cmpfnc, void *cmpdata);
    2.74 -
    2.75 -/**
    2.76 - * Inserts an element at the beginning of the list, if it is not present in
    2.77 - * the list, using a UcxAllocator.
    2.78 - * 
    2.79 - * <b>Note:</b> You should not try to store a freshly allocated object. Since
    2.80 - * it might be a duplicate, the memory allocated for that copy would be leaking
    2.81 - * afterwards.
    2.82 - * 
    2.83 - * <b>Deprecation notice:</b> This function is considered to do more harm than
    2.84 - * it adds usefulness and is going to be removed in a future UCX release.
    2.85 - * 
    2.86 - * @param allocator the allocator to use
    2.87 - * @param list the list where to prepend the data, or <code>NULL</code> to
    2.88 - * create a new list
    2.89 - * @param data the data to insert
    2.90 - * @param cmpfnc the compare function
    2.91 - * @param cmpdata additional data for the compare function
    2.92 - * @return a pointer to the new list head
    2.93 - * @see ucx_list_prepend_a()
    2.94 - */
    2.95 -UcxList *ucx_list_prepend_once_a(UcxAllocator *allocator,
    2.96 -        UcxList *list, void *data, cmp_func cmpfnc, void *cmpdata);
    2.97  
    2.98  /**
    2.99   * Inserts an element at the beginning of the list.
     3.1 --- a/test/list_tests.c	Wed May 16 19:33:31 2018 +0200
     3.2 +++ b/test/list_tests.c	Thu May 17 11:13:02 2018 +0200
     3.3 @@ -68,27 +68,6 @@
     3.4      ucx_list_free(list);
     3.5  }
     3.6  
     3.7 -UCX_TEST(test_ucx_list_append_once) {
     3.8 -    UcxList *list, *first;
     3.9 -    list = first = ucx_list_append_once(NULL, (void*)"Hello", ucx_cmp_str, NULL);
    3.10 -    UCX_TEST_BEGIN
    3.11 -    
    3.12 -    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    3.13 -            "failed");
    3.14 -    
    3.15 -    list = ucx_list_append_once(list, (void*)"Hello", ucx_cmp_str, NULL);
    3.16 -    list = ucx_list_append_once(list, (void*)" World!", ucx_cmp_str, NULL);
    3.17 -    
    3.18 -    UCX_TEST_ASSERT(list == first, "does not return first element");
    3.19 -    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    3.20 -            "'Hello' was not inserted _once_");
    3.21 -    UCX_TEST_ASSERT(list->next->prev == list, "failed");
    3.22 -    UCX_TEST_ASSERT(list->next->next == NULL, "right not terminated");
    3.23 -    UCX_TEST_END
    3.24 -    
    3.25 -    ucx_list_free(list);
    3.26 -}
    3.27 -
    3.28  UCX_TEST(test_ucx_list_equals) {
    3.29      const char *hello = "Hello";
    3.30      const char *world = " World!";
     4.1 --- a/test/list_tests.h	Wed May 16 19:33:31 2018 +0200
     4.2 +++ b/test/list_tests.h	Thu May 17 11:13:02 2018 +0200
     4.3 @@ -43,7 +43,6 @@
     4.4  
     4.5  UCX_TEST(test_ucx_list_append);
     4.6  UCX_TEST(test_ucx_list_prepend);
     4.7 -UCX_TEST(test_ucx_list_append_once);
     4.8  UCX_TEST(test_ucx_list_equals);
     4.9  UCX_TEST(test_ucx_list_concat);
    4.10  UCX_TEST(test_ucx_list_size);
     5.1 --- a/test/main.c	Wed May 16 19:33:31 2018 +0200
     5.2 +++ b/test/main.c	Thu May 17 11:13:02 2018 +0200
     5.3 @@ -144,7 +144,6 @@
     5.4          /* UcxList Tests */
     5.5          ucx_test_register(suite, test_ucx_list_append);
     5.6          ucx_test_register(suite, test_ucx_list_prepend);
     5.7 -        ucx_test_register(suite, test_ucx_list_append_once);
     5.8          ucx_test_register(suite, test_ucx_list_equals);
     5.9          ucx_test_register(suite, test_ucx_list_concat);
    5.10          ucx_test_register(suite, test_ucx_list_size);

mercurial