Thu, 23 May 2024 20:31:37 +0200
fix inconsistent use of item_size and elem_size
src/array_list.c | file | annotate | diff | comparison | revisions | |
src/cx/array_list.h | file | annotate | diff | comparison | revisions | |
src/cx/collection.h | file | annotate | diff | comparison | revisions | |
src/cx/hash_map.h | file | annotate | diff | comparison | revisions | |
src/cx/linked_list.h | file | annotate | diff | comparison | revisions | |
src/cx/map.h | file | annotate | diff | comparison | revisions | |
src/hash_map.c | file | annotate | diff | comparison | revisions | |
src/linked_list.c | file | annotate | diff | comparison | revisions | |
src/list.c | file | annotate | diff | comparison | revisions | |
tests/test_hash_map.c | file | annotate | diff | comparison | revisions | |
tests/test_list.c | file | annotate | diff | comparison | revisions |
1.1 --- a/src/array_list.c Thu May 23 20:29:28 2024 +0200 1.2 +++ b/src/array_list.c Thu May 23 20:31:37 2024 +0200 1.3 @@ -194,13 +194,13 @@ 1.4 if (list->base.simple_destructor) { 1.5 for (size_t i = 0; i < list->base.size; i++) { 1.6 cx_invoke_simple_destructor(list, ptr); 1.7 - ptr += list->base.item_size; 1.8 + ptr += list->base.elem_size; 1.9 } 1.10 } 1.11 if (list->base.advanced_destructor) { 1.12 for (size_t i = 0; i < list->base.size; i++) { 1.13 cx_invoke_advanced_destructor(list, ptr); 1.14 - ptr += list->base.item_size; 1.15 + ptr += list->base.elem_size; 1.16 } 1.17 } 1.18 1.19 @@ -223,7 +223,7 @@ 1.20 // do we need to move some elements? 1.21 if (index < list->base.size) { 1.22 char const *first_to_move = (char const *) arl->data; 1.23 - first_to_move += index * list->base.item_size; 1.24 + first_to_move += index * list->base.elem_size; 1.25 size_t elems_to_move = list->base.size - index; 1.26 size_t start_of_moved = index + n; 1.27 1.28 @@ -233,7 +233,7 @@ 1.29 &arl->capacity, 1.30 start_of_moved, 1.31 first_to_move, 1.32 - list->base.item_size, 1.33 + list->base.elem_size, 1.34 elems_to_move, 1.35 &arl->reallocator 1.36 )) { 1.37 @@ -253,7 +253,7 @@ 1.38 &arl->capacity, 1.39 index, 1.40 array, 1.41 - list->base.item_size, 1.42 + list->base.elem_size, 1.43 n, 1.44 &arl->reallocator 1.45 )) { 1.46 @@ -286,7 +286,7 @@ 1.47 ); 1.48 if (result == 0 && prepend != 0) { 1.49 iter->index++; 1.50 - iter->elem_handle = ((char *) iter->elem_handle) + list->base.item_size; 1.51 + iter->elem_handle = ((char *) iter->elem_handle) + list->base.elem_size; 1.52 } 1.53 return result; 1.54 } else { 1.55 @@ -308,7 +308,7 @@ 1.56 } 1.57 1.58 // content destruction 1.59 - cx_invoke_destructor(list, ((char *) arl->data) + index * list->base.item_size); 1.60 + cx_invoke_destructor(list, ((char *) arl->data) + index * list->base.elem_size); 1.61 1.62 // short-circuit removal of last element 1.63 if (index == list->base.size - 1) { 1.64 @@ -322,8 +322,8 @@ 1.65 &list->base.size, 1.66 &arl->capacity, 1.67 index, 1.68 - ((char *) arl->data) + (index + 1) * list->base.item_size, 1.69 - list->base.item_size, 1.70 + ((char *) arl->data) + (index + 1) * list->base.elem_size, 1.71 + list->base.elem_size, 1.72 list->base.size - index - 1, 1.73 &arl->reallocator 1.74 ); 1.75 @@ -346,17 +346,17 @@ 1.76 if (list->base.simple_destructor) { 1.77 for (size_t i = 0; i < list->base.size; i++) { 1.78 cx_invoke_simple_destructor(list, ptr); 1.79 - ptr += list->base.item_size; 1.80 + ptr += list->base.elem_size; 1.81 } 1.82 } 1.83 if (list->base.advanced_destructor) { 1.84 for (size_t i = 0; i < list->base.size; i++) { 1.85 cx_invoke_advanced_destructor(list, ptr); 1.86 - ptr += list->base.item_size; 1.87 + ptr += list->base.elem_size; 1.88 } 1.89 } 1.90 1.91 - memset(arl->data, 0, list->base.size * list->base.item_size); 1.92 + memset(arl->data, 0, list->base.size * list->base.elem_size); 1.93 list->base.size = 0; 1.94 } 1.95 1.96 @@ -367,7 +367,7 @@ 1.97 ) { 1.98 if (i >= list->base.size || j >= list->base.size) return 1; 1.99 cx_array_list *arl = (cx_array_list *) list; 1.100 - cx_array_swap(arl->data, list->base.item_size, i, j); 1.101 + cx_array_swap(arl->data, list->base.elem_size, i, j); 1.102 return 0; 1.103 } 1.104 1.105 @@ -378,7 +378,7 @@ 1.106 if (index < list->base.size) { 1.107 cx_array_list const *arl = (cx_array_list const *) list; 1.108 char *space = arl->data; 1.109 - return space + index * list->base.item_size; 1.110 + return space + index * list->base.elem_size; 1.111 } else { 1.112 return NULL; 1.113 } 1.114 @@ -405,7 +405,7 @@ 1.115 return i; 1.116 } 1.117 } 1.118 - cur += list->base.item_size; 1.119 + cur += list->base.elem_size; 1.120 } 1.121 1.122 return -1; 1.123 @@ -415,7 +415,7 @@ 1.124 assert(list->base.cmpfunc != NULL); 1.125 qsort(((cx_array_list *) list)->data, 1.126 list->base.size, 1.127 - list->base.item_size, 1.128 + list->base.elem_size, 1.129 list->base.cmpfunc 1.130 ); 1.131 } 1.132 @@ -433,8 +433,8 @@ 1.133 if (d != 0) { 1.134 return d; 1.135 } 1.136 - left += list->base.item_size; 1.137 - right += other->base.item_size; 1.138 + left += list->base.elem_size; 1.139 + right += other->base.elem_size; 1.140 } 1.141 return 0; 1.142 } else { 1.143 @@ -447,7 +447,7 @@ 1.144 void *data = ((cx_array_list const *) list)->data; 1.145 size_t half = list->base.size / 2; 1.146 for (size_t i = 0; i < half; i++) { 1.147 - cx_array_swap(data, list->base.item_size, i, list->base.size - 1 - i); 1.148 + cx_array_swap(data, list->base.elem_size, i, list->base.size - 1 - i); 1.149 } 1.150 } 1.151 1.152 @@ -471,7 +471,7 @@ 1.153 iter->index++; 1.154 iter->elem_handle = 1.155 ((char *) iter->elem_handle) 1.156 - + ((struct cx_list_s const *) iter->src_handle.c)->base.item_size; 1.157 + + ((struct cx_list_s const *) iter->src_handle.c)->base.elem_size; 1.158 } 1.159 } 1.160 1.161 @@ -485,7 +485,7 @@ 1.162 iter->index--; 1.163 if (iter->index < list->base.base.size) { 1.164 iter->elem_handle = ((char *) list->data) 1.165 - + iter->index * list->base.base.item_size; 1.166 + + iter->index * list->base.base.elem_size; 1.167 } 1.168 } 1.169 1.170 @@ -500,7 +500,7 @@ 1.171 iter.index = index; 1.172 iter.src_handle.c = list; 1.173 iter.elem_handle = cx_arl_at(list, index); 1.174 - iter.elem_size = list->base.item_size; 1.175 + iter.elem_size = list->base.elem_size; 1.176 iter.elem_count = list->base.size; 1.177 iter.base.valid = cx_arl_iter_valid; 1.178 iter.base.current = cx_arl_iter_current; 1.179 @@ -530,7 +530,7 @@ 1.180 CxList *cxArrayListCreate( 1.181 CxAllocator const *allocator, 1.182 cx_compare_func comparator, 1.183 - size_t item_size, 1.184 + size_t elem_size, 1.185 size_t initial_capacity 1.186 ) { 1.187 if (allocator == NULL) { 1.188 @@ -544,17 +544,17 @@ 1.189 list->base.base.allocator = allocator; 1.190 list->capacity = initial_capacity; 1.191 1.192 - if (item_size > 0) { 1.193 - list->base.base.item_size = item_size; 1.194 + if (elem_size > 0) { 1.195 + list->base.base.elem_size = elem_size; 1.196 list->base.base.cmpfunc = comparator; 1.197 } else { 1.198 - item_size = sizeof(void *); 1.199 + elem_size = sizeof(void *); 1.200 list->base.base.cmpfunc = comparator == NULL ? cx_cmp_ptr : comparator; 1.201 cxListStorePointers((CxList *) list); 1.202 } 1.203 1.204 - // allocate the array after the real item_size is known 1.205 - list->data = cxCalloc(allocator, initial_capacity, item_size); 1.206 + // allocate the array after the real elem_size is known 1.207 + list->data = cxCalloc(allocator, initial_capacity, elem_size); 1.208 if (list->data == NULL) { 1.209 cxFree(allocator, list); 1.210 return NULL;
2.1 --- a/src/cx/array_list.h Thu May 23 20:29:28 2024 +0200 2.2 +++ b/src/cx/array_list.h Thu May 23 20:31:37 2024 +0200 2.3 @@ -226,9 +226,9 @@ 2.4 ) __attribute__((__nonnull__)); 2.5 2.6 /** 2.7 - * Allocates an array list for storing elements with \p item_size bytes each. 2.8 + * Allocates an array list for storing elements with \p elem_size bytes each. 2.9 * 2.10 - * If \p item_size is CX_STORE_POINTERS, the created list will be created as if 2.11 + * If \p elem_size is CX_STORE_POINTERS, the created list will be created as if 2.12 * cxListStorePointers() was called immediately after creation and the compare 2.13 * function will be automatically set to cx_cmp_ptr(), if none is given. 2.14 * 2.15 @@ -237,34 +237,34 @@ 2.16 * @param comparator the comparator for the elements 2.17 * (if \c NULL, and the list is not storing pointers, sort and find 2.18 * functions will not work) 2.19 - * @param item_size the size of each element in bytes 2.20 + * @param elem_size the size of each element in bytes 2.21 * @param initial_capacity the initial number of elements the array can store 2.22 * @return the created list 2.23 */ 2.24 CxList *cxArrayListCreate( 2.25 CxAllocator const *allocator, 2.26 cx_compare_func comparator, 2.27 - size_t item_size, 2.28 + size_t elem_size, 2.29 size_t initial_capacity 2.30 ); 2.31 2.32 /** 2.33 - * Allocates an array list for storing elements with \p item_size bytes each. 2.34 + * Allocates an array list for storing elements with \p elem_size bytes each. 2.35 * 2.36 * The list will use the cxDefaultAllocator and \em NO compare function. 2.37 * If you want to call functions that need a compare function, you have to 2.38 * set it immediately after creation or use cxArrayListCreate(). 2.39 * 2.40 - * If \p item_size is CX_STORE_POINTERS, the created list will be created as if 2.41 + * If \p elem_size is CX_STORE_POINTERS, the created list will be created as if 2.42 * cxListStorePointers() was called immediately after creation and the compare 2.43 * function will be automatically set to cx_cmp_ptr(). 2.44 * 2.45 - * @param item_size the size of each element in bytes 2.46 + * @param elem_size the size of each element in bytes 2.47 * @param initial_capacity the initial number of elements the array can store 2.48 * @return the created list 2.49 */ 2.50 -#define cxArrayListCreateSimple(item_size, initial_capacity) \ 2.51 - cxArrayListCreate(NULL, NULL, item_size, initial_capacity) 2.52 +#define cxArrayListCreateSimple(elem_size, initial_capacity) \ 2.53 + cxArrayListCreate(NULL, NULL, elem_size, initial_capacity) 2.54 2.55 #ifdef __cplusplus 2.56 } // extern "C"
3.1 --- a/src/cx/collection.h Thu May 23 20:29:28 2024 +0200 3.2 +++ b/src/cx/collection.h Thu May 23 20:31:37 2024 +0200 3.3 @@ -64,7 +64,7 @@ 3.4 /** 3.5 * The size of each element. 3.6 */ 3.7 - size_t item_size; 3.8 + size_t elem_size; 3.9 /** 3.10 * The number of currently stored elements. 3.11 */
4.1 --- a/src/cx/hash_map.h Thu May 23 20:29:28 2024 +0200 4.2 +++ b/src/cx/hash_map.h Thu May 23 20:31:37 2024 +0200 4.3 @@ -69,7 +69,7 @@ 4.4 * 4.5 * If \p buckets is zero, an implementation defined default will be used. 4.6 * 4.7 - * If \p item_size is CX_STORE_POINTERS, the created map will be created as if 4.8 + * If \p elem_size is CX_STORE_POINTERS, the created map will be created as if 4.9 * cxMapStorePointers() was called immediately after creation. 4.10 * 4.11 * @note Iterators provided by this hash map implementation provide the remove operation. 4.12 @@ -91,7 +91,7 @@ 4.13 /** 4.14 * Creates a new hash map with a default number of buckets. 4.15 * 4.16 - * If \p item_size is CX_STORE_POINTERS, the created map will be created as if 4.17 + * If \p elem_size is CX_STORE_POINTERS, the created map will be created as if 4.18 * cxMapStorePointers() was called immediately after creation. 4.19 * 4.20 * @note Iterators provided by this hash map implementation provide the remove operation.
5.1 --- a/src/cx/linked_list.h Thu May 23 20:29:28 2024 +0200 5.2 +++ b/src/cx/linked_list.h Thu May 23 20:31:37 2024 +0200 5.3 @@ -50,9 +50,9 @@ 5.4 extern unsigned cx_linked_list_swap_sbo_size; 5.5 5.6 /** 5.7 - * Allocates a linked list for storing elements with \p item_size bytes each. 5.8 + * Allocates a linked list for storing elements with \p elem_size bytes each. 5.9 * 5.10 - * If \p item_size is CX_STORE_POINTERS, the created list will be created as if 5.11 + * If \p elem_size is CX_STORE_POINTERS, the created list will be created as if 5.12 * cxListStorePointers() was called immediately after creation and the compare 5.13 * function will be automatically set to cx_cmp_ptr(), if none is given. 5.14 * 5.15 @@ -61,31 +61,31 @@ 5.16 * @param comparator the comparator for the elements 5.17 * (if \c NULL, and the list is not storing pointers, sort and find 5.18 * functions will not work) 5.19 - * @param item_size the size of each element in bytes 5.20 + * @param elem_size the size of each element in bytes 5.21 * @return the created list 5.22 */ 5.23 CxList *cxLinkedListCreate( 5.24 CxAllocator const *allocator, 5.25 cx_compare_func comparator, 5.26 - size_t item_size 5.27 + size_t elem_size 5.28 ); 5.29 5.30 /** 5.31 - * Allocates a linked list for storing elements with \p item_size bytes each. 5.32 + * Allocates a linked list for storing elements with \p elem_size bytes each. 5.33 * 5.34 * The list will use cxDefaultAllocator and no comparator function. If you want 5.35 * to call functions that need a comparator, you must either set one immediately 5.36 * after list creation or use cxLinkedListCreate(). 5.37 * 5.38 - * If \p item_size is CX_STORE_POINTERS, the created list will be created as if 5.39 + * If \p elem_size is CX_STORE_POINTERS, the created list will be created as if 5.40 * cxListStorePointers() was called immediately after creation and the compare 5.41 * function will be automatically set to cx_cmp_ptr(). 5.42 * 5.43 - * @param item_size the size of each element in bytes 5.44 + * @param elem_size the size of each element in bytes 5.45 * @return the created list 5.46 */ 5.47 -#define cxLinkedListCreateSimple(item_size) \ 5.48 - cxLinkedListCreate(NULL, NULL, item_size) 5.49 +#define cxLinkedListCreateSimple(elem_size) \ 5.50 + cxLinkedListCreate(NULL, NULL, elem_size) 5.51 5.52 /** 5.53 * Finds the node at a certain index.
6.1 --- a/src/cx/map.h Thu May 23 20:29:28 2024 +0200 6.2 +++ b/src/cx/map.h Thu May 23 20:31:37 2024 +0200 6.3 @@ -184,7 +184,7 @@ 6.4 __attribute__((__nonnull__)) 6.5 static inline void cxMapStorePointers(CxMap *map) { 6.6 map->base.store_pointer = true; 6.7 - map->base.item_size = sizeof(void *); 6.8 + map->base.elem_size = sizeof(void *); 6.9 } 6.10 6.11
7.1 --- a/src/hash_map.c Thu May 23 20:29:28 2024 +0200 7.2 +++ b/src/hash_map.c Thu May 23 20:31:37 2024 +0200 7.3 @@ -107,13 +107,13 @@ 7.4 if (map->base.store_pointer) { 7.5 memcpy(elm->data, &value, sizeof(void *)); 7.6 } else { 7.7 - memcpy(elm->data, value, map->base.item_size); 7.8 + memcpy(elm->data, value, map->base.elem_size); 7.9 } 7.10 } else { 7.11 // allocate new element 7.12 struct cx_hash_map_element_s *e = cxMalloc( 7.13 allocator, 7.14 - sizeof(struct cx_hash_map_element_s) + map->base.item_size 7.15 + sizeof(struct cx_hash_map_element_s) + map->base.elem_size 7.16 ); 7.17 if (e == NULL) { 7.18 return -1; 7.19 @@ -123,7 +123,7 @@ 7.20 if (map->base.store_pointer) { 7.21 memcpy(e->data, &value, sizeof(void *)); 7.22 } else { 7.23 - memcpy(e->data, value, map->base.item_size); 7.24 + memcpy(e->data, value, map->base.elem_size); 7.25 } 7.26 7.27 // copy the key 7.28 @@ -342,7 +342,7 @@ 7.29 iter.base.current = cx_hash_map_iter_current_key; 7.30 break; 7.31 case CX_MAP_ITERATOR_VALUES: 7.32 - iter.elem_size = map->base.item_size; 7.33 + iter.elem_size = map->base.elem_size; 7.34 iter.base.current = cx_hash_map_iter_current_value; 7.35 break; 7.36 default: 7.37 @@ -417,10 +417,10 @@ 7.38 7.39 if (itemsize > 0) { 7.40 map->base.base.store_pointer = false; 7.41 - map->base.base.item_size = itemsize; 7.42 + map->base.base.elem_size = itemsize; 7.43 } else { 7.44 map->base.base.store_pointer = true; 7.45 - map->base.base.item_size = sizeof(void *); 7.46 + map->base.base.elem_size = sizeof(void *); 7.47 } 7.48 7.49 return (CxMap *) map;
8.1 --- a/src/linked_list.c Thu May 23 20:29:28 2024 +0200 8.2 +++ b/src/linked_list.c Thu May 23 20:31:37 2024 +0200 8.3 @@ -518,14 +518,14 @@ 8.4 8.5 // create the new new_node 8.6 cx_linked_list_node *new_node = cxMalloc(list->base.allocator, 8.7 - sizeof(cx_linked_list_node) + list->base.item_size); 8.8 + sizeof(cx_linked_list_node) + list->base.elem_size); 8.9 8.10 // sortir if failed 8.11 if (new_node == NULL) return 1; 8.12 8.13 // initialize new new_node 8.14 new_node->prev = new_node->next = NULL; 8.15 - memcpy(new_node->payload, elem, list->base.item_size); 8.16 + memcpy(new_node->payload, elem, list->base.elem_size); 8.17 8.18 // insert 8.19 cx_linked_list *ll = (cx_linked_list *) list; 8.20 @@ -566,7 +566,7 @@ 8.21 // we can add the remaining nodes and immedately advance to the inserted node 8.22 char const *source = array; 8.23 for (size_t i = 1; i < n; i++) { 8.24 - source += list->base.item_size; 8.25 + source += list->base.elem_size; 8.26 if (0 != cx_ll_insert_at(list, node, source)) { 8.27 return i; 8.28 } 8.29 @@ -707,7 +707,7 @@ 8.30 } 8.31 } 8.32 8.33 - if (list->base.item_size > CX_LINKED_LIST_SWAP_SBO_SIZE) { 8.34 + if (list->base.elem_size > CX_LINKED_LIST_SWAP_SBO_SIZE) { 8.35 cx_linked_list_node *prev = nleft->prev; 8.36 cx_linked_list_node *next = nright->next; 8.37 cx_linked_list_node *midstart = nleft->next; 8.38 @@ -739,9 +739,9 @@ 8.39 } else { 8.40 // swap payloads to avoid relinking 8.41 char buf[CX_LINKED_LIST_SWAP_SBO_SIZE]; 8.42 - memcpy(buf, nleft->payload, list->base.item_size); 8.43 - memcpy(nleft->payload, nright->payload, list->base.item_size); 8.44 - memcpy(nright->payload, buf, list->base.item_size); 8.45 + memcpy(buf, nleft->payload, list->base.elem_size); 8.46 + memcpy(nleft->payload, nright->payload, list->base.elem_size); 8.47 + memcpy(nright->payload, buf, list->base.elem_size); 8.48 } 8.49 8.50 return 0; 8.51 @@ -871,7 +871,7 @@ 8.52 iter.index = index; 8.53 iter.src_handle.c = list; 8.54 iter.elem_handle = cx_ll_node_at((cx_linked_list const *) list, index); 8.55 - iter.elem_size = list->base.item_size; 8.56 + iter.elem_size = list->base.elem_size; 8.57 iter.elem_count = list->base.size; 8.58 iter.base.valid = cx_ll_iter_valid; 8.59 iter.base.current = cx_ll_iter_current; 8.60 @@ -934,7 +934,7 @@ 8.61 CxList *cxLinkedListCreate( 8.62 CxAllocator const *allocator, 8.63 cx_compare_func comparator, 8.64 - size_t item_size 8.65 + size_t elem_size 8.66 ) { 8.67 if (allocator == NULL) { 8.68 allocator = cxDefaultAllocator; 8.69 @@ -946,8 +946,8 @@ 8.70 list->base.cl = &cx_linked_list_class; 8.71 list->base.base.allocator = allocator; 8.72 8.73 - if (item_size > 0) { 8.74 - list->base.base.item_size = item_size; 8.75 + if (elem_size > 0) { 8.76 + list->base.base.elem_size = elem_size; 8.77 list->base.base.cmpfunc = comparator; 8.78 } else { 8.79 list->base.base.cmpfunc = comparator == NULL ? cx_cmp_ptr : comparator;
9.1 --- a/src/list.c Thu May 23 20:29:28 2024 +0200 9.2 +++ b/src/list.c Thu May 23 20:31:37 2024 +0200 9.3 @@ -188,7 +188,7 @@ 9.4 } 9.5 9.6 void cxListStorePointers(CxList *list) { 9.7 - list->base.item_size = sizeof(void *); 9.8 + list->base.elem_size = sizeof(void *); 9.9 list->base.store_pointer = true; 9.10 list->climpl = list->cl; 9.11 list->cl = &cx_pointer_list_class;
10.1 --- a/tests/test_hash_map.c Thu May 23 20:29:28 2024 +0200 10.2 +++ b/tests/test_hash_map.c Thu May 23 20:31:37 2024 +0200 10.3 @@ -42,7 +42,7 @@ 10.4 for(size_t i = 0 ; i < hmap->bucket_count ; i++) { 10.5 CX_TEST_ASSERT(hmap->buckets[i] == NULL); 10.6 } 10.7 - CX_TEST_ASSERT(map->base.item_size == 1); 10.8 + CX_TEST_ASSERT(map->base.elem_size == 1); 10.9 CX_TEST_ASSERT(map->base.size == 0); 10.10 CX_TEST_ASSERT(map->base.allocator == allocator); 10.11 CX_TEST_ASSERT(!map->base.store_pointer); 10.12 @@ -52,7 +52,7 @@ 10.13 CX_TEST_ASSERT(map->base.destructor_data == NULL); 10.14 cxMapStorePointers(map); 10.15 CX_TEST_ASSERT(map->base.store_pointer); 10.16 - CX_TEST_ASSERT(map->base.item_size == sizeof(void *)); 10.17 + CX_TEST_ASSERT(map->base.elem_size == sizeof(void *)); 10.18 cxMapStoreObjects(map); 10.19 CX_TEST_ASSERT(!map->base.store_pointer); 10.20 10.21 @@ -76,7 +76,7 @@ 10.22 CX_TEST_ASSERT(map->base.size == 0); 10.23 CX_TEST_ASSERT(map->base.allocator == allocator); 10.24 CX_TEST_ASSERT(map->base.store_pointer); 10.25 - CX_TEST_ASSERT(map->base.item_size == sizeof(void *)); 10.26 + CX_TEST_ASSERT(map->base.elem_size == sizeof(void *)); 10.27 10.28 cxMapDestroy(map); 10.29 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); 10.30 @@ -566,7 +566,7 @@ 10.31 // by using that the values in our test data are unique strings 10.32 // we can re-use a similar approach as above 10.33 CxIterator valiter = cxMapIteratorValues(map); 10.34 - CX_TEST_ASSERT(valiter.elem_size == map->base.item_size); 10.35 + CX_TEST_ASSERT(valiter.elem_size == map->base.elem_size); 10.36 CX_TEST_ASSERT(valiter.elem_count == map->base.size); 10.37 char const** values = calloc(map->base.size, sizeof(char const*)); 10.38 cx_foreach(char const*, elem, valiter) {
11.1 --- a/tests/test_list.c Thu May 23 20:29:28 2024 +0200 11.2 +++ b/tests/test_list.c Thu May 23 20:31:37 2024 +0200 11.3 @@ -706,7 +706,7 @@ 11.4 CX_TEST_DO { 11.5 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, sizeof(int)); 11.6 CX_TEST_ASSERT(list != NULL); 11.7 - CX_TEST_ASSERT(list->base.item_size == sizeof(int)); 11.8 + CX_TEST_ASSERT(list->base.elem_size == sizeof(int)); 11.9 CX_TEST_ASSERT(list->base.simple_destructor == NULL); 11.10 CX_TEST_ASSERT(list->base.advanced_destructor == NULL); 11.11 CX_TEST_ASSERT(list->base.destructor_data == NULL); 11.12 @@ -724,7 +724,7 @@ 11.13 CxList *list = cxLinkedListCreateSimple(sizeof(int)); 11.14 CX_TEST_DO { 11.15 CX_TEST_ASSERT(list != NULL); 11.16 - CX_TEST_ASSERT(list->base.item_size == sizeof(int)); 11.17 + CX_TEST_ASSERT(list->base.elem_size == sizeof(int)); 11.18 CX_TEST_ASSERT(list->base.simple_destructor == NULL); 11.19 CX_TEST_ASSERT(list->base.advanced_destructor == NULL); 11.20 CX_TEST_ASSERT(list->base.destructor_data == NULL); 11.21 @@ -741,7 +741,7 @@ 11.22 CX_TEST_DO { 11.23 CX_TEST_ASSERT(!cxListIsStoringPointers(list)); 11.24 cxListStorePointers(list); 11.25 - CX_TEST_ASSERT(list->base.item_size == sizeof(void *)); 11.26 + CX_TEST_ASSERT(list->base.elem_size == sizeof(void *)); 11.27 CX_TEST_ASSERT(list->cl != NULL); 11.28 CX_TEST_ASSERT(list->climpl != NULL); 11.29 CX_TEST_ASSERT(cxListIsStoringPointers(list)); 11.30 @@ -757,7 +757,7 @@ 11.31 CxList *list = cxLinkedListCreateSimple(CX_STORE_POINTERS); 11.32 CX_TEST_DO { 11.33 CX_TEST_ASSERT(list != NULL); 11.34 - CX_TEST_ASSERT(list->base.item_size == sizeof(void*)); 11.35 + CX_TEST_ASSERT(list->base.elem_size == sizeof(void*)); 11.36 CX_TEST_ASSERT(list->base.simple_destructor == NULL); 11.37 CX_TEST_ASSERT(list->base.advanced_destructor == NULL); 11.38 CX_TEST_ASSERT(list->base.destructor_data == NULL); 11.39 @@ -776,7 +776,7 @@ 11.40 CX_TEST_DO { 11.41 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, sizeof(int), 8); 11.42 CX_TEST_ASSERT(list != NULL); 11.43 - CX_TEST_ASSERT(list->base.item_size == sizeof(int)); 11.44 + CX_TEST_ASSERT(list->base.elem_size == sizeof(int)); 11.45 CX_TEST_ASSERT(list->base.simple_destructor == NULL); 11.46 CX_TEST_ASSERT(list->base.advanced_destructor == NULL); 11.47 CX_TEST_ASSERT(list->base.destructor_data == NULL); 11.48 @@ -794,7 +794,7 @@ 11.49 CxList *list = cxArrayListCreateSimple(sizeof(int), 8); 11.50 CX_TEST_DO { 11.51 CX_TEST_ASSERT(list != NULL); 11.52 - CX_TEST_ASSERT(list->base.item_size == sizeof(int)); 11.53 + CX_TEST_ASSERT(list->base.elem_size == sizeof(int)); 11.54 CX_TEST_ASSERT(list->base.simple_destructor == NULL); 11.55 CX_TEST_ASSERT(list->base.advanced_destructor == NULL); 11.56 CX_TEST_ASSERT(list->base.destructor_data == NULL); 11.57 @@ -810,7 +810,7 @@ 11.58 CxList *list = cxArrayListCreateSimple(CX_STORE_POINTERS, 8); 11.59 CX_TEST_DO { 11.60 CX_TEST_ASSERT(list != NULL); 11.61 - CX_TEST_ASSERT(list->base.item_size == sizeof(void*)); 11.62 + CX_TEST_ASSERT(list->base.elem_size == sizeof(void*)); 11.63 CX_TEST_ASSERT(list->base.simple_destructor == NULL); 11.64 CX_TEST_ASSERT(list->base.advanced_destructor == NULL); 11.65 CX_TEST_ASSERT(list->base.destructor_data == NULL); 11.66 @@ -1207,7 +1207,7 @@ 11.67 int *testdata = int_test_data_added_to_list(list, isptrlist, len); 11.68 11.69 CxIterator iter = cxListIterator(list); 11.70 - CX_TEST_ASSERT(iter.elem_size == list->base.item_size); 11.71 + CX_TEST_ASSERT(iter.elem_size == list->base.elem_size); 11.72 CX_TEST_ASSERT(iter.elem_count == list->base.size); 11.73 size_t i = 0; 11.74 cx_foreach(int*, x, iter) { 11.75 @@ -1225,7 +1225,7 @@ 11.76 CX_TEST_ASSERT(i == 0); 11.77 i = len / 2; 11.78 CxIterator mut_iter = cxListMutIteratorAt(list, i); 11.79 - CX_TEST_ASSERT(mut_iter.elem_size == list->base.item_size); 11.80 + CX_TEST_ASSERT(mut_iter.elem_size == list->base.elem_size); 11.81 CX_TEST_ASSERT(mut_iter.elem_count == list->base.size); 11.82 size_t j = 0; 11.83 cx_foreach(int*, x, mut_iter) {