made the code work with g++ without errors (but warnings)

Fri, 12 Oct 2012 12:08:34 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 12 Oct 2012 12:08:34 +0200
changeset 71
303dabadff1c
parent 69
fb59270b1de3
child 72
bb3eae81aae8

made the code work with g++ without errors (but warnings)

test/buffer_tests.c file | annotate | diff | comparison | revisions
test/dlist_tests.c file | annotate | diff | comparison | revisions
test/list_tests.c file | annotate | diff | comparison | revisions
test/map_tests.c file | annotate | diff | comparison | revisions
test/string_tests.c file | annotate | diff | comparison | revisions
ucx/map.h file | annotate | diff | comparison | revisions
ucx/string.c file | annotate | diff | comparison | revisions
     1.1 --- a/test/buffer_tests.c	Fri Oct 12 10:54:55 2012 +0200
     1.2 +++ b/test/buffer_tests.c	Fri Oct 12 12:08:34 2012 +0200
     1.3 @@ -123,7 +123,7 @@
     1.4      UCX_TEST_ASSERT(ucx_buffer_eof(b), "eof shall be set");
     1.5  
     1.6      ucx_buffer_seek(b, 8, SEEK_SET);
     1.7 -    r = ucx_buffer_write("not", 1, 3, b);
     1.8 +    r = ucx_buffer_write((void*)"not", 1, 3, b);
     1.9      UCX_TEST_ASSERT(r == 3, "three bytes should be replace");
    1.10      UCX_TEST_ASSERT(memcmp(buffer, "this is not too much", 16) == 0,
    1.11              "modified buffer is incorrect");
     2.1 --- a/test/dlist_tests.c	Fri Oct 12 10:54:55 2012 +0200
     2.2 +++ b/test/dlist_tests.c	Fri Oct 12 12:08:34 2012 +0200
     2.3 @@ -5,13 +5,13 @@
     2.4  #include "dlist_tests.h"
     2.5  
     2.6  UCX_TEST_IMPLEMENT(test_ucx_dlist_append) {
     2.7 -    UcxDlist *list = ucx_dlist_append(NULL, "Hello");
     2.8 +    UcxDlist *list = ucx_dlist_append(NULL, (void*)"Hello");
     2.9      UCX_TEST_BEGIN
    2.10      
    2.11      UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    2.12              "failed");
    2.13      
    2.14 -    list = ucx_dlist_append(list, " World!");
    2.15 +    list = ucx_dlist_append(list, (void*)" World!");
    2.16      
    2.17      UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    2.18              "failed");
    2.19 @@ -22,10 +22,10 @@
    2.20  }
    2.21  
    2.22  UCX_TEST_IMPLEMENT(test_ucx_dlist_prepend) {
    2.23 -    UcxDlist *list = ucx_dlist_prepend(NULL, " World!");
    2.24 +    UcxDlist *list = ucx_dlist_prepend(NULL, (void*)" World!");
    2.25      UCX_TEST_BEGIN
    2.26  
    2.27 -    list = ucx_dlist_prepend(list, "Hello");
    2.28 +    list = ucx_dlist_prepend(list, (void*)"Hello");
    2.29      
    2.30      UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    2.31              "failed");
    2.32 @@ -38,12 +38,12 @@
    2.33  }
    2.34  
    2.35  UCX_TEST_IMPLEMENT(test_ucx_dlist_equals) {
    2.36 -    UcxDlist *list = ucx_dlist_append(NULL, "Hello");
    2.37 -    list = ucx_dlist_append(list, " World!");
    2.38 -    UcxDlist *list2 = ucx_dlist_prepend(NULL, " World!");
    2.39 -    list2 = ucx_dlist_prepend(list2, "Hello");
    2.40 -    UcxDlist *list3 = ucx_dlist_prepend(NULL, " Welt!");
    2.41 -    list3 = ucx_dlist_prepend(list3, "Hallo");
    2.42 +    UcxDlist *list = ucx_dlist_append(NULL, (void*)"Hello");
    2.43 +    list = ucx_dlist_append(list, (void*)" World!");
    2.44 +    UcxDlist *list2 = ucx_dlist_prepend(NULL, (void*)" World!");
    2.45 +    list2 = ucx_dlist_prepend(list2, (void*)"Hello");
    2.46 +    UcxDlist *list3 = ucx_dlist_prepend(NULL, (void*)" Welt!");
    2.47 +    list3 = ucx_dlist_prepend(list3, (void*)"Hallo");
    2.48      UCX_TEST_BEGIN
    2.49      
    2.50      UCX_TEST_ASSERT(ucx_dlist_equals(list, list2, cmp_string, NULL), "failed");
    2.51 @@ -56,8 +56,8 @@
    2.52  }
    2.53  
    2.54  UCX_TEST_IMPLEMENT(test_ucx_dlist_concat) {
    2.55 -    UcxDlist *list = ucx_dlist_append(NULL, "Hello");
    2.56 -    UcxDlist *list2 = ucx_dlist_prepend(NULL, " World!");
    2.57 +    UcxDlist *list = ucx_dlist_append(NULL, (void*)"Hello");
    2.58 +    UcxDlist *list2 = ucx_dlist_prepend(NULL, (void*)" World!");
    2.59      UCX_TEST_BEGIN
    2.60      
    2.61      list = ucx_dlist_concat(list, list2);
    2.62 @@ -73,12 +73,12 @@
    2.63  }
    2.64  
    2.65  UCX_TEST_IMPLEMENT(test_ucx_dlist_size) {
    2.66 -    UcxDlist *list = ucx_dlist_append(NULL, "This ");
    2.67 +    UcxDlist *list = ucx_dlist_append(NULL, (void*)"This ");
    2.68      UCX_TEST_BEGIN
    2.69 -    list = ucx_dlist_append(list, "list ");
    2.70 -    list = ucx_dlist_append(list, "has ");
    2.71 -    list = ucx_dlist_append(list, "size ");
    2.72 -    list = ucx_dlist_append(list, "5!");
    2.73 +    list = ucx_dlist_append(list, (void*)"list ");
    2.74 +    list = ucx_dlist_append(list, (void*)"has ");
    2.75 +    list = ucx_dlist_append(list, (void*)"size ");
    2.76 +    list = ucx_dlist_append(list, (void*)"5!");
    2.77      
    2.78      UCX_TEST_ASSERT(ucx_dlist_size(list) == 5, "failed");
    2.79      
    2.80 @@ -87,10 +87,10 @@
    2.81  }
    2.82  
    2.83  UCX_TEST_IMPLEMENT(test_ucx_dlist_first) {
    2.84 -    UcxDlist *list = ucx_dlist_append(NULL, "Find ");
    2.85 +    UcxDlist *list = ucx_dlist_append(NULL, (void*)"Find ");
    2.86      UCX_TEST_BEGIN
    2.87 -    list = ucx_dlist_append(list, "the ");
    2.88 -    list = ucx_dlist_append(list, "first!");
    2.89 +    list = ucx_dlist_append(list, (void*)"the ");
    2.90 +    list = ucx_dlist_append(list, (void*)"first!");
    2.91      
    2.92      const char* first = (const char*) (ucx_dlist_first(list)->data);
    2.93      
    2.94 @@ -101,10 +101,10 @@
    2.95  }
    2.96  
    2.97  UCX_TEST_IMPLEMENT(test_ucx_dlist_last) {
    2.98 -    UcxDlist *list = ucx_dlist_append(NULL, "Find ");
    2.99 +    UcxDlist *list = ucx_dlist_append(NULL, (void*)"Find ");
   2.100      UCX_TEST_BEGIN
   2.101 -    list = ucx_dlist_append(list, "the ");
   2.102 -    list = ucx_dlist_append(list, "last!");
   2.103 +    list = ucx_dlist_append(list, (void*)"the ");
   2.104 +    list = ucx_dlist_append(list, (void*)"last!");
   2.105      
   2.106      const char* last = (const char*) (ucx_dlist_last(list)->data);
   2.107      
   2.108 @@ -115,10 +115,10 @@
   2.109  }
   2.110  
   2.111  UCX_TEST_IMPLEMENT(test_ucx_dlist_get) {
   2.112 -    UcxDlist *list = ucx_dlist_append(NULL, "Find ");
   2.113 +    UcxDlist *list = ucx_dlist_append(NULL, (void*)"Find ");
   2.114      UCX_TEST_BEGIN
   2.115 -    list = ucx_dlist_append(list, "the ");
   2.116 -    list = ucx_dlist_append(list, "mid!");
   2.117 +    list = ucx_dlist_append(list, (void*)"the ");
   2.118 +    list = ucx_dlist_append(list, (void*)"mid!");
   2.119      
   2.120      const char* mid = (const char*) (ucx_dlist_get(list, 1)->data);
   2.121      
   2.122 @@ -129,10 +129,10 @@
   2.123  }
   2.124  
   2.125  UCX_TEST_IMPLEMENT(test_ucx_dlist_remove) {
   2.126 -    UcxDlist *list = ucx_dlist_append(NULL, "Hello");
   2.127 +    UcxDlist *list = ucx_dlist_append(NULL, (void*)"Hello");
   2.128      UCX_TEST_BEGIN
   2.129 -    list = ucx_dlist_append(list, " fucking");
   2.130 -    list = ucx_dlist_append(list, " World!");
   2.131 +    list = ucx_dlist_append(list, (void*)" fucking");
   2.132 +    list = ucx_dlist_append(list, (void*)" World!");
   2.133      
   2.134      list = ucx_dlist_remove(list, ucx_dlist_get(list, 1));
   2.135      
   2.136 @@ -175,21 +175,21 @@
   2.137  }
   2.138  
   2.139  UCX_TEST_IMPLEMENT(test_ucx_dlist_sort) {
   2.140 -    UcxDlist *list = ucx_dlist_append(NULL, "this");
   2.141 -    list = ucx_dlist_append(list, "is");
   2.142 -    list = ucx_dlist_append(list, "a");
   2.143 -    list = ucx_dlist_append(list, "test");
   2.144 -    list = ucx_dlist_append(list, "for");
   2.145 -    list = ucx_dlist_append(list, "partial");
   2.146 -    list = ucx_dlist_append(list, "correctness");
   2.147 +    UcxDlist *list = ucx_dlist_append(NULL, (void*)"this");
   2.148 +    list = ucx_dlist_append(list, (void*)"is");
   2.149 +    list = ucx_dlist_append(list, (void*)"a");
   2.150 +    list = ucx_dlist_append(list, (void*)"test");
   2.151 +    list = ucx_dlist_append(list, (void*)"for");
   2.152 +    list = ucx_dlist_append(list, (void*)"partial");
   2.153 +    list = ucx_dlist_append(list, (void*)"correctness");
   2.154  
   2.155 -    UcxDlist *expected = ucx_dlist_append(NULL, "a");
   2.156 -    expected = ucx_dlist_append(expected, "correctness");
   2.157 -    expected = ucx_dlist_append(expected, "for");
   2.158 -    expected = ucx_dlist_append(expected, "is");
   2.159 -    expected = ucx_dlist_append(expected, "partial");
   2.160 -    expected = ucx_dlist_append(expected, "test");
   2.161 -    expected = ucx_dlist_append(expected, "this");
   2.162 +    UcxDlist *expected = ucx_dlist_append(NULL, (void*)"a");
   2.163 +    expected = ucx_dlist_append(expected, (void*)"correctness");
   2.164 +    expected = ucx_dlist_append(expected, (void*)"for");
   2.165 +    expected = ucx_dlist_append(expected, (void*)"is");
   2.166 +    expected = ucx_dlist_append(expected, (void*)"partial");
   2.167 +    expected = ucx_dlist_append(expected, (void*)"test");
   2.168 +    expected = ucx_dlist_append(expected, (void*)"this");
   2.169  
   2.170      list = ucx_dlist_sort(list, cmp_string, NULL);
   2.171  
     3.1 --- a/test/list_tests.c	Fri Oct 12 10:54:55 2012 +0200
     3.2 +++ b/test/list_tests.c	Fri Oct 12 12:08:34 2012 +0200
     3.3 @@ -5,12 +5,12 @@
     3.4  #include "list_tests.h"
     3.5  
     3.6  UCX_TEST_IMPLEMENT(test_ucx_list_append) {
     3.7 -    UcxList *list = ucx_list_append(NULL, "Hello");
     3.8 +    UcxList *list = ucx_list_append(NULL, (void*)"Hello");
     3.9      UCX_TEST_BEGIN
    3.10      UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    3.11              "failed");
    3.12      
    3.13 -    list = ucx_list_append(list, " World!");
    3.14 +    list = ucx_list_append(list, (void*)" World!");
    3.15      
    3.16      UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    3.17              "failed");
    3.18 @@ -21,9 +21,9 @@
    3.19  }
    3.20  
    3.21  UCX_TEST_IMPLEMENT(test_ucx_list_prepend) {
    3.22 -    UcxList *list = ucx_list_prepend(NULL, " World!");
    3.23 +    UcxList *list = ucx_list_prepend(NULL, (void*)" World!");
    3.24      UCX_TEST_BEGIN
    3.25 -    list = ucx_list_prepend(list, "Hello");
    3.26 +    list = ucx_list_prepend(list, (void*)"Hello");
    3.27      
    3.28      UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    3.29              "failed");
    3.30 @@ -36,12 +36,12 @@
    3.31  }
    3.32  
    3.33  UCX_TEST_IMPLEMENT(test_ucx_list_equals) {
    3.34 -    UcxList *list = ucx_list_append(NULL, "Hello");
    3.35 -    list = ucx_list_append(list, " World!");
    3.36 -    UcxList *list2 = ucx_list_prepend(NULL, " World!");
    3.37 -    list2 = ucx_list_prepend(list2, "Hello");
    3.38 -    UcxList *list3 = ucx_list_prepend(NULL, " Welt!");
    3.39 -    list3 = ucx_list_prepend(list3, "Hallo");
    3.40 +    UcxList *list = ucx_list_append(NULL, (void*)"Hello");
    3.41 +    list = ucx_list_append(list, (void*)" World!");
    3.42 +    UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!");
    3.43 +    list2 = ucx_list_prepend(list2, (void*)"Hello");
    3.44 +    UcxList *list3 = ucx_list_prepend(NULL, (void*)" Welt!");
    3.45 +    list3 = ucx_list_prepend(list3, (void*)"Hallo");
    3.46      
    3.47      UCX_TEST_BEGIN
    3.48      UCX_TEST_ASSERT(ucx_list_equals(list, list2, cmp_string, NULL), "failed");
    3.49 @@ -54,8 +54,8 @@
    3.50  }
    3.51  
    3.52  UCX_TEST_IMPLEMENT(test_ucx_list_concat) {
    3.53 -    UcxList *list = ucx_list_append(NULL, "Hello");
    3.54 -    UcxList *list2 = ucx_list_prepend(NULL, " World!");
    3.55 +    UcxList *list = ucx_list_append(NULL, (void*)"Hello");
    3.56 +    UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!");
    3.57      
    3.58      list = ucx_list_concat(list, list2);
    3.59      UCX_TEST_BEGIN
    3.60 @@ -74,12 +74,12 @@
    3.61  }
    3.62  
    3.63  UCX_TEST_IMPLEMENT(test_ucx_list_size) {
    3.64 -    UcxList *list = ucx_list_append(NULL, "This ");
    3.65 +    UcxList *list = ucx_list_append(NULL, (void*)"This ");
    3.66      UCX_TEST_BEGIN
    3.67 -    list = ucx_list_append(list, "list ");
    3.68 -    list = ucx_list_append(list, "has ");
    3.69 -    list = ucx_list_append(list, "size ");
    3.70 -    list = ucx_list_append(list, "5!");
    3.71 +    list = ucx_list_append(list, (void*)"list ");
    3.72 +    list = ucx_list_append(list, (void*)"has ");
    3.73 +    list = ucx_list_append(list, (void*)"size ");
    3.74 +    list = ucx_list_append(list, (void*)"5!");
    3.75      
    3.76      UCX_TEST_ASSERT(ucx_list_size(list) == 5, "failed");
    3.77      
    3.78 @@ -88,10 +88,10 @@
    3.79  }
    3.80  
    3.81  UCX_TEST_IMPLEMENT(test_ucx_list_last) {
    3.82 -    UcxList *list = ucx_list_append(NULL, "Find ");
    3.83 +    UcxList *list = ucx_list_append(NULL, (void*)"Find ");
    3.84      UCX_TEST_BEGIN
    3.85 -    list = ucx_list_append(list, "the ");
    3.86 -    list = ucx_list_append(list, "last!");
    3.87 +    list = ucx_list_append(list, (void*)"the ");
    3.88 +    list = ucx_list_append(list, (void*)"last!");
    3.89      
    3.90      const char* last = (const char*) (ucx_list_last(list)->data);
    3.91      
    3.92 @@ -103,10 +103,10 @@
    3.93  }
    3.94  
    3.95  UCX_TEST_IMPLEMENT(test_ucx_list_get) {
    3.96 -    UcxList *list = ucx_list_append(NULL, "Find ");
    3.97 +    UcxList *list = ucx_list_append(NULL, (void*)"Find ");
    3.98      UCX_TEST_BEGIN
    3.99 -    list = ucx_list_append(list, "the ");
   3.100 -    list = ucx_list_append(list, "mid!");
   3.101 +    list = ucx_list_append(list, (void*)"the ");
   3.102 +    list = ucx_list_append(list, (void*)"mid!");
   3.103      
   3.104      const char* mid = (const char*) (ucx_list_get(list, 1)->data);
   3.105      
   3.106 @@ -117,10 +117,10 @@
   3.107  }
   3.108  
   3.109  UCX_TEST_IMPLEMENT(test_ucx_list_remove) {
   3.110 -    UcxList *list = ucx_list_append(NULL, "Hello");
   3.111 +    UcxList *list = ucx_list_append(NULL, (void*)"Hello");
   3.112      UCX_TEST_BEGIN
   3.113 -    list = ucx_list_append(list, " fucking");
   3.114 -    list = ucx_list_append(list, " World!");
   3.115 +    list = ucx_list_append(list, (void*)" fucking");
   3.116 +    list = ucx_list_append(list, (void*)" World!");
   3.117      
   3.118      list = ucx_list_remove(list, ucx_list_get(list, 1));
   3.119      
   3.120 @@ -163,21 +163,21 @@
   3.121  }
   3.122  
   3.123  UCX_TEST_IMPLEMENT(test_ucx_list_sort) {
   3.124 -    UcxList *list = ucx_list_append(NULL, "this");
   3.125 -    list = ucx_list_append(list, "is");
   3.126 -    list = ucx_list_append(list, "a");
   3.127 -    list = ucx_list_append(list, "test");
   3.128 -    list = ucx_list_append(list, "for");
   3.129 -    list = ucx_list_append(list, "partial");
   3.130 -    list = ucx_list_append(list, "correctness");
   3.131 +    UcxList *list = ucx_list_append(NULL, (void*)"this");
   3.132 +    list = ucx_list_append(list, (void*)"is");
   3.133 +    list = ucx_list_append(list, (void*)"a");
   3.134 +    list = ucx_list_append(list, (void*)"test");
   3.135 +    list = ucx_list_append(list, (void*)"for");
   3.136 +    list = ucx_list_append(list, (void*)"partial");
   3.137 +    list = ucx_list_append(list, (void*)"correctness");
   3.138  
   3.139 -    UcxList *expected = ucx_list_append(NULL, "a");
   3.140 -    expected = ucx_list_append(expected, "correctness");
   3.141 -    expected = ucx_list_append(expected, "for");
   3.142 -    expected = ucx_list_append(expected, "is");
   3.143 -    expected = ucx_list_append(expected, "partial");
   3.144 -    expected = ucx_list_append(expected, "test");
   3.145 -    expected = ucx_list_append(expected, "this");
   3.146 +    UcxList *expected = ucx_list_append(NULL, (void*)"a");
   3.147 +    expected = ucx_list_append(expected, (void*)"correctness");
   3.148 +    expected = ucx_list_append(expected, (void*)"for");
   3.149 +    expected = ucx_list_append(expected, (void*)"is");
   3.150 +    expected = ucx_list_append(expected, (void*)"partial");
   3.151 +    expected = ucx_list_append(expected, (void*)"test");
   3.152 +    expected = ucx_list_append(expected, (void*)"this");
   3.153  
   3.154      list = ucx_list_sort(list, cmp_string, NULL);
   3.155  
     4.1 --- a/test/map_tests.c	Fri Oct 12 10:54:55 2012 +0200
     4.2 +++ b/test/map_tests.c	Fri Oct 12 12:08:34 2012 +0200
     4.3 @@ -15,7 +15,7 @@
     4.4  }
     4.5  
     4.6  UCX_TEST_IMPLEMENT(test_ucx_key) {
     4.7 -    UcxKey key = ucx_key("This is a text.", 15);
     4.8 +    UcxKey key = ucx_key((void*)"This is a text.", 15);
     4.9      UCX_TEST_BEGIN
    4.10      UCX_TEST_ASSERT(strncmp((const char*)key.data, "This is a text.", 15) == 0,
    4.11              "failed");
    4.12 @@ -194,12 +194,12 @@
    4.13  UCX_TEST_IMPLEMENT(test_ucx_map_store_load) {
    4.14      UcxMap *map = ucx_map_new(4);
    4.15  
    4.16 -    ucx_map_cstr_put(map, "test", "test");
    4.17 -    ucx_map_cstr_put(map, "key", "value");
    4.18 -    ucx_map_cstr_put(map, "other.very.long.key", "value");
    4.19 -    ucx_map_cstr_put(map, "testkey", "testvalue");
    4.20 -    ucx_map_cstr_put(map, "simple", "not a key but an extremely long value "
    4.21 -            "to test if the buffer extension works as designed");
    4.22 +    ucx_map_cstr_put(map, "test", (void*)"test");
    4.23 +    ucx_map_cstr_put(map, "key", (void*)"value");
    4.24 +    ucx_map_cstr_put(map, "other.very.long.key", (void*)"value");
    4.25 +    ucx_map_cstr_put(map, "testkey", (void*)"testvalue");
    4.26 +    ucx_map_cstr_put(map, "simple", (void*)"not a key but an extremely long "
    4.27 +            "value to test if the buffer extension works as designed");
    4.28  
    4.29      UCX_TEST_BEGIN
    4.30      FILE *f = tmpfile();
    4.31 @@ -259,10 +259,10 @@
    4.32  UCX_TEST_IMPLEMENT(test_ucx_map_store_load_with_mempool) {
    4.33      UcxMap *map = ucx_map_new(4);
    4.34  
    4.35 -    ucx_map_cstr_put(map, "test", "test");
    4.36 -    ucx_map_cstr_put(map, "key", "value");
    4.37 -    ucx_map_cstr_put(map, "testkey", "testvalue");
    4.38 -    ucx_map_cstr_put(map, "simple", "a simple value");
    4.39 +    ucx_map_cstr_put(map, "test", (void*)"test");
    4.40 +    ucx_map_cstr_put(map, "key", (void*)"value");
    4.41 +    ucx_map_cstr_put(map, "testkey", (void*)"testvalue");
    4.42 +    ucx_map_cstr_put(map, "simple", (void*)"a simple value");
    4.43  
    4.44      UCX_TEST_BEGIN
    4.45      FILE *f = tmpfile();
    4.46 @@ -297,9 +297,9 @@
    4.47  UCX_TEST_IMPLEMENT(test_ucx_map_clone) {
    4.48      UcxMap *map = ucx_map_new(4);
    4.49      
    4.50 -    ucx_map_cstr_put(map, "key1", "value1");
    4.51 -    ucx_map_cstr_put(map, "key2", "value2");
    4.52 -    ucx_map_cstr_put(map, "key3", "value3");
    4.53 +    ucx_map_cstr_put(map, "key1", (void*)"value1");
    4.54 +    ucx_map_cstr_put(map, "key2", (void*)"value2");
    4.55 +    ucx_map_cstr_put(map, "key3", (void*)"value3");
    4.56      
    4.57      UcxMap *clone = ucx_map_clone(map, NULL, NULL);
    4.58      
     5.1 --- a/test/string_tests.c	Fri Oct 12 10:54:55 2012 +0200
     5.2 +++ b/test/string_tests.c	Fri Oct 12 12:08:34 2012 +0200
     5.3 @@ -158,10 +158,8 @@
     5.4      /* exact match (exm) */
     5.5      n = 0;
     5.6      list = sstrsplit(test, ST("this,is,a,csv,string"), &n);
     5.7 -    UCX_TEST_ASSERT(n == 1, "exm, list length must be 1");
     5.8 -    UCX_TEST_ASSERT(list[0].length == 0, "exm, single item must be empty");
     5.9 -    UCX_TEST_ASSERT(strcmp(test.ptr, original) == 0,
    5.10 -            "exm, original has been modified");
    5.11 +    UCX_TEST_ASSERT(n == 0, "exm, list length must be 0");
    5.12 +    UCX_TEST_ASSERT(list == NULL, "exm, list must be NULL");
    5.13      free(list);
    5.14  
    5.15      /* substring (subs) */
     6.1 --- a/ucx/map.h	Fri Oct 12 10:54:55 2012 +0200
     6.2 +++ b/ucx/map.h	Fri Oct 12 12:08:34 2012 +0200
     6.3 @@ -67,12 +67,18 @@
     6.4  void* ucx_map_get(UcxMap *map, UcxKey key);
     6.5  void* ucx_map_remove(UcxMap *map, UcxKey key);
     6.6  
     6.7 -#define ucx_map_sstr_put(m, s, d) ucx_map_put(m, ucx_key(s.ptr, s.length), d)
     6.8 -#define ucx_map_cstr_put(m, s, d) ucx_map_put(m, ucx_key(s, 1+strlen(s)), d)
     6.9 -#define ucx_map_sstr_get(m, s) ucx_map_get(m, ucx_key(s.ptr, s.length))
    6.10 -#define ucx_map_cstr_get(m, s) ucx_map_get(m, ucx_key(s, 1+strlen(s)))
    6.11 -#define ucx_map_sstr_remove(m, s) ucx_map_remove(m, ucx_key(s.ptr, s.length))
    6.12 -#define ucx_map_cstr_remove(m, s) ucx_map_remove(m, ucx_key(s, 1+strlen(s)))
    6.13 +#define ucx_map_sstr_put(m, s, d) \
    6.14 +    ucx_map_put(m, ucx_key((void*)s.ptr, s.length), d)
    6.15 +#define ucx_map_cstr_put(m, s, d) \
    6.16 +    ucx_map_put(m, ucx_key((void*)s, 1+strlen(s)), d)
    6.17 +#define ucx_map_sstr_get(m, s) \
    6.18 +    ucx_map_get(m, ucx_key((void*)s.ptr, s.length))
    6.19 +#define ucx_map_cstr_get(m, s) \
    6.20 +    ucx_map_get(m, ucx_key((void*)s, 1+strlen(s)))
    6.21 +#define ucx_map_sstr_remove(m, s) \
    6.22 +    ucx_map_remove(m, ucx_key((void*)s.ptr, s.length))
    6.23 +#define ucx_map_cstr_remove(m, s) \
    6.24 +    ucx_map_remove(m, ucx_key((void*)s, 1+strlen(s)))
    6.25  
    6.26  UcxKey ucx_key(void *data, size_t len);
    6.27  
     7.1 --- a/ucx/string.c	Fri Oct 12 10:54:55 2012 +0200
     7.2 +++ b/ucx/string.c	Fri Oct 12 12:08:34 2012 +0200
     7.3 @@ -110,9 +110,8 @@
     7.4  
     7.5      /* special case: exact match - no processing needed */
     7.6      if (s.length == d.length && strncmp(s.ptr, d.ptr, s.length) == 0) {
     7.7 -        result = (sstr_t*) malloc(sizeof(sstr_t));
     7.8 -        result[0] = sstrn("", 0);
     7.9 -        return result;
    7.10 +        *n = 0;
    7.11 +        return NULL;
    7.12      }
    7.13      sstr_t sv = sstrdup(s);
    7.14  

mercurial