Mon, 14 May 2018 18:12:14 +0200
renames ucx_strcmp() to ucx_cmp_str()
src/ucx/avl.h | file | annotate | diff | comparison | revisions | |
src/ucx/utils.h | file | annotate | diff | comparison | revisions | |
src/utils.c | file | annotate | diff | comparison | revisions | |
test/list_tests.c | file | annotate | diff | comparison | revisions |
1.1 --- a/src/ucx/avl.h Mon May 14 17:56:03 2018 +0200 1.2 +++ b/src/ucx/avl.h Mon May 14 18:12:14 2018 +0200 1.3 @@ -125,7 +125,7 @@ 1.4 * 1.5 * The cmpfunc should be capable of comparing two keys within this AVL tree. 1.6 * So if you want to use null terminated strings as keys, you could use the 1.7 - * ucx_strcmp() function here. 1.8 + * ucx_cmp_str() function here. 1.9 * 1.10 * @param cmpfunc the compare function that shall be used 1.11 * @param allocator the UcxAllocator that shall be used
2.1 --- a/src/ucx/utils.h Mon May 14 17:56:03 2018 +0200 2.2 +++ b/src/ucx/utils.h Mon May 14 18:12:14 2018 +0200 2.3 @@ -144,7 +144,7 @@ 2.4 * @param data omitted 2.5 * @return the result of strcmp(s1, s2) 2.6 */ 2.7 -int ucx_strcmp(const void *s1, const void *s2, void *data); 2.8 +int ucx_cmp_str(const void *s1, const void *s2, void *data); 2.9 2.10 /** 2.11 * Wraps the strncmp function.
3.1 --- a/src/utils.c Mon May 14 17:56:03 2018 +0200 3.2 +++ b/src/utils.c Mon May 14 18:12:14 2018 +0200 3.3 @@ -88,7 +88,7 @@ 3.4 3.5 /* COMPARE FUNCTIONS */ 3.6 3.7 -int ucx_strcmp(const void *s1, const void *s2, void *data) { 3.8 +int ucx_cmp_str(const void *s1, const void *s2, void *data) { 3.9 return strcmp((const char*)s1, (const char*)s2); 3.10 } 3.11
4.1 --- a/test/list_tests.c Mon May 14 17:56:03 2018 +0200 4.2 +++ b/test/list_tests.c Mon May 14 18:12:14 2018 +0200 4.3 @@ -70,14 +70,14 @@ 4.4 4.5 UCX_TEST(test_ucx_list_append_once) { 4.6 UcxList *list, *first; 4.7 - list = first = ucx_list_append_once(NULL, (void*)"Hello", ucx_strcmp, NULL); 4.8 + list = first = ucx_list_append_once(NULL, (void*)"Hello", ucx_cmp_str, NULL); 4.9 UCX_TEST_BEGIN 4.10 4.11 UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0, 4.12 "failed"); 4.13 4.14 - list = ucx_list_append_once(list, (void*)"Hello", ucx_strcmp, NULL); 4.15 - list = ucx_list_append_once(list, (void*)" World!", ucx_strcmp, NULL); 4.16 + list = ucx_list_append_once(list, (void*)"Hello", ucx_cmp_str, NULL); 4.17 + list = ucx_list_append_once(list, (void*)" World!", ucx_cmp_str, NULL); 4.18 4.19 UCX_TEST_ASSERT(list == first, "does not return first element"); 4.20 UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0, 4.21 @@ -102,8 +102,8 @@ 4.22 list4 = ucx_list_prepend(list4, (void*)"Hello"); 4.23 UCX_TEST_BEGIN 4.24 4.25 - UCX_TEST_ASSERT(ucx_list_equals(list, list4, ucx_strcmp, NULL), "failed"); 4.26 - UCX_TEST_ASSERT(!ucx_list_equals(list, list3, ucx_strcmp, NULL), "failed"); 4.27 + UCX_TEST_ASSERT(ucx_list_equals(list, list4, ucx_cmp_str, NULL), "failed"); 4.28 + UCX_TEST_ASSERT(!ucx_list_equals(list, list3, ucx_cmp_str, NULL), "failed"); 4.29 UCX_TEST_ASSERT(ucx_list_equals(list, list2, NULL, NULL), "failed"); 4.30 4.31 UCX_TEST_END 4.32 @@ -245,15 +245,15 @@ 4.33 4.34 UCX_TEST_BEGIN 4.35 4.36 - UCX_TEST_ASSERT(ucx_list_find(l,(void*)"some ",ucx_strcmp,NULL) == 1, 4.37 + UCX_TEST_ASSERT(ucx_list_find(l,(void*)"some ",ucx_cmp_str,NULL) == 1, 4.38 "doesn't find string"); 4.39 - UCX_TEST_ASSERT(ucx_list_find(l,(void*)"a",ucx_strcmp,NULL) == -1, 4.40 + UCX_TEST_ASSERT(ucx_list_find(l,(void*)"a",ucx_cmp_str,NULL) == -1, 4.41 "finds non-existing string"); 4.42 4.43 UCX_TEST_ASSERT(ucx_list_find(l,(void*)teststr,NULL,NULL) == 2, 4.44 "doesn't find integer without cmp_func"); 4.45 4.46 - UCX_TEST_ASSERT(ucx_list_find(NULL, (void*)"some ",ucx_strcmp,NULL) == -1, 4.47 + UCX_TEST_ASSERT(ucx_list_find(NULL, (void*)"some ",ucx_cmp_str,NULL) == -1, 4.48 "empty list"); 4.49 4.50 UCX_TEST_END 4.51 @@ -267,9 +267,9 @@ 4.52 4.53 UCX_TEST_BEGIN 4.54 4.55 - UCX_TEST_ASSERT(ucx_list_contains(l,(void*)"a ",ucx_strcmp,NULL), 4.56 + UCX_TEST_ASSERT(ucx_list_contains(l,(void*)"a ",ucx_cmp_str,NULL), 4.57 "false negative"); 4.58 - UCX_TEST_ASSERT(!ucx_list_contains(l,(void*)"a",ucx_strcmp,NULL), 4.59 + UCX_TEST_ASSERT(!ucx_list_contains(l,(void*)"a",ucx_cmp_str,NULL), 4.60 "false positive"); 4.61 4.62 UCX_TEST_END 4.63 @@ -356,7 +356,7 @@ 4.64 UcxList *copy = ucx_list_clone(list, ucx_strcpy, NULL); 4.65 UCX_TEST_BEGIN 4.66 4.67 - UCX_TEST_ASSERT(ucx_list_equals(list, copy, ucx_strcmp, NULL), "failed"); 4.68 + UCX_TEST_ASSERT(ucx_list_equals(list, copy, ucx_cmp_str, NULL), "failed"); 4.69 UCX_TEST_ASSERT(hello != copy->data, "first element is no copy"); 4.70 UCX_TEST_ASSERT(world != copy->next->data, "second element is no copy"); 4.71 4.72 @@ -405,11 +405,11 @@ 4.73 expected = ucx_list_append(expected, (void*)"this"); 4.74 expected = ucx_list_append(expected, (void*)"this"); 4.75 4.76 - list = ucx_list_sort(list, ucx_strcmp, NULL); 4.77 + list = ucx_list_sort(list, ucx_cmp_str, NULL); 4.78 4.79 UCX_TEST_BEGIN 4.80 UCX_TEST_ASSERT( 4.81 - ucx_list_equals(list, expected, ucx_strcmp, NULL), "failed"); 4.82 + ucx_list_equals(list, expected, ucx_cmp_str, NULL), "failed"); 4.83 UCX_TEST_ASSERT(ucx_list_size(list) == 16, "list has now a wrong size"); 4.84 UcxList *l = list; 4.85 UCX_TEST_ASSERT(l->prev == NULL, "prev field of first entry is not null"); 4.86 @@ -417,7 +417,7 @@ 4.87 UCX_TEST_ASSERT(l->next->prev == l, "next or prev pointer corrupted"); 4.88 l = l->next; 4.89 } 4.90 - UCX_TEST_ASSERT(!ucx_list_sort(NULL, ucx_strcmp, NULL), 4.91 + UCX_TEST_ASSERT(!ucx_list_sort(NULL, ucx_cmp_str, NULL), 4.92 "failed to sort empty list"); 4.93 UCX_TEST_END 4.94