Sat, 28 Sep 2024 15:47:28 +0200
move all const keywords to the west - fixes #426
--- a/docs/src/features.md Wed Sep 18 00:02:18 2024 +0200 +++ b/docs/src/features.md Sat Sep 28 15:47:28 2024 +0200 @@ -278,7 +278,7 @@ size_t *size, size_t *capacity, // optional size_t index, - void const *src, + const void *src, size_t elem_size, size_t elem_count, struct cx_array_reallocator_s *reallocator // optional @@ -330,7 +330,7 @@ Secondly, the iterator method is a bit more complete. The signature is as follows: ```c -CxIterator (*iterator)(CxMap const *map, enum cx_map_iterator_type type); +CxIterator (*iterator)(const CxMap *map, enum cx_map_iterator_type type); ``` There are three map iterator types: for values, for keys, for pairs. Depending on the iterator type requested, you need to create an iterator with the correct methods that
--- a/src/allocator.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/allocator.c Sat Sep 28 15:47:28 2024 +0200 @@ -92,14 +92,14 @@ // IMPLEMENTATION OF HIGH LEVEL API void *cxMalloc( - CxAllocator const *allocator, + const CxAllocator *allocator, size_t n ) { return allocator->cl->malloc(allocator->data, n); } void *cxRealloc( - CxAllocator const *allocator, + const CxAllocator *allocator, void *mem, size_t n ) { @@ -107,7 +107,7 @@ } int cxReallocate( - CxAllocator const *allocator, + const CxAllocator *allocator, void **mem, size_t n ) { @@ -121,7 +121,7 @@ } void *cxCalloc( - CxAllocator const *allocator, + const CxAllocator *allocator, size_t nelem, size_t n ) { @@ -129,7 +129,7 @@ } void cxFree( - CxAllocator const *allocator, + const CxAllocator *allocator, void *mem ) { allocator->cl->free(allocator->data, mem);
--- a/src/array_list.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/array_list.c Sat Sep 28 15:47:28 2024 +0200 @@ -55,7 +55,7 @@ size_t *size, size_t *capacity, size_t index, - void const *src, + const void *src, size_t elem_size, size_t elem_count, struct cx_array_reallocator_s *reallocator @@ -125,7 +125,7 @@ size_t *size, size_t *capacity, cx_compare_func cmp_func, - void const *sorted_data, + const void *sorted_data, size_t elem_size, size_t elem_count, struct cx_array_reallocator_s *reallocator @@ -166,7 +166,7 @@ // declare the source and destination indices/pointers size_t si = 0, di = 0; - char const *src = sorted_data; + const char *src = sorted_data; char *dest = *target; // find the first insertion point @@ -232,10 +232,10 @@ } size_t cx_array_binary_search_inf( - void const *arr, + const void *arr, size_t size, size_t elem_size, - void const *elem, + const void *elem, cx_compare_func cmp_func ) { // special case: empty array @@ -245,7 +245,7 @@ int result; // cast the array pointer to something we can use offsets with - char const *array = arr; + const char *array = arr; // check the first array element result = cmp_func(elem, array); @@ -269,7 +269,7 @@ while (left_index <= right_index) { pivot_index = left_index + (right_index - left_index) / 2; - char const *arr_elem = array + pivot_index * elem_size; + const char *arr_elem = array + pivot_index * elem_size; result = cmp_func(elem, arr_elem); if (result == 0) { // found it! @@ -347,7 +347,7 @@ struct cx_array_reallocator_s *alloc ) { // retrieve the pointer to the list allocator - CxAllocator const *al = alloc->ptr1; + const CxAllocator *al = alloc->ptr1; // use the list allocator to reallocate the memory return cxRealloc(al, array, capacity * elem_size); @@ -378,7 +378,7 @@ static size_t cx_arl_insert_array( struct cx_list_s *list, size_t index, - void const *array, + const void *array, size_t n ) { // out of bounds and special case check @@ -389,7 +389,7 @@ // do we need to move some elements? if (index < list->collection.size) { - char const *first_to_move = (char const *) arl->data; + const char *first_to_move = (const char *) arl->data; first_to_move += index * list->collection.elem_size; size_t elems_to_move = list->collection.size - index; size_t start_of_moved = index + n; @@ -433,7 +433,7 @@ static size_t cx_arl_insert_sorted( struct cx_list_s *list, - void const *sorted_data, + const void *sorted_data, size_t n ) { // get a correctly typed pointer to the list @@ -459,14 +459,14 @@ static int cx_arl_insert_element( struct cx_list_s *list, size_t index, - void const *element + const void *element ) { return 1 != cx_arl_insert_array(list, index, element, 1); } static int cx_arl_insert_iter( struct cx_iterator_s *iter, - void const *elem, + const void *elem, int prepend ) { struct cx_list_s *list = iter->src_handle.m; @@ -570,11 +570,11 @@ } static void *cx_arl_at( - struct cx_list_s const *list, + const struct cx_list_s *list, size_t index ) { if (index < list->collection.size) { - cx_array_list const *arl = (cx_array_list const *) list; + const cx_array_list *arl = (const cx_array_list *) list; char *space = arl->data; return space + index * list->collection.elem_size; } else { @@ -584,12 +584,12 @@ static ssize_t cx_arl_find_remove( struct cx_list_s *list, - void const *elem, + const void *elem, bool remove ) { assert(list->collection.cmpfunc != NULL); assert(list->collection.size < SIZE_MAX / 2); - char *cur = ((cx_array_list const *) list)->data; + char *cur = ((const cx_array_list *) list)->data; for (ssize_t i = 0; i < (ssize_t) list->collection.size; i++) { if (0 == list->collection.cmpfunc(elem, cur)) { @@ -619,13 +619,13 @@ } static int cx_arl_compare( - struct cx_list_s const *list, - struct cx_list_s const *other + const struct cx_list_s *list, + const struct cx_list_s *other ) { assert(list->collection.cmpfunc != NULL); if (list->collection.size == other->collection.size) { - char const *left = ((cx_array_list const *) list)->data; - char const *right = ((cx_array_list const *) other)->data; + const char *left = ((const cx_array_list *) list)->data; + const char *right = ((const cx_array_list *) other)->data; for (size_t i = 0; i < list->collection.size; i++) { int d = list->collection.cmpfunc(left, right); if (d != 0) { @@ -642,21 +642,21 @@ static void cx_arl_reverse(struct cx_list_s *list) { if (list->collection.size < 2) return; - void *data = ((cx_array_list const *) list)->data; + void *data = ((const cx_array_list *) list)->data; size_t half = list->collection.size / 2; for (size_t i = 0; i < half; i++) { cx_array_swap(data, list->collection.elem_size, i, list->collection.size - 1 - i); } } -static bool cx_arl_iter_valid(void const *it) { - struct cx_iterator_s const *iter = it; - struct cx_list_s const *list = iter->src_handle.c; +static bool cx_arl_iter_valid(const void *it) { + const struct cx_iterator_s *iter = it; + const struct cx_list_s *list = iter->src_handle.c; return iter->index < list->collection.size; } -static void *cx_arl_iter_current(void const *it) { - struct cx_iterator_s const *iter = it; +static void *cx_arl_iter_current(const void *it) { + const struct cx_iterator_s *iter = it; return iter->elem_handle; } @@ -669,13 +669,13 @@ iter->index++; iter->elem_handle = ((char *) iter->elem_handle) - + ((struct cx_list_s const *) iter->src_handle.c)->collection.elem_size; + + ((const struct cx_list_s *) iter->src_handle.c)->collection.elem_size; } } static void cx_arl_iter_prev(void *it) { struct cx_iterator_s *iter = it; - cx_array_list const* list = iter->src_handle.c; + const cx_array_list *list = iter->src_handle.c; if (iter->base.remove) { iter->base.remove = false; cx_arl_remove(iter->src_handle.m, iter->index); @@ -689,7 +689,7 @@ static struct cx_iterator_s cx_arl_iterator( - struct cx_list_s const *list, + const struct cx_list_s *list, size_t index, bool backwards ) { @@ -727,7 +727,7 @@ }; CxList *cxArrayListCreate( - CxAllocator const *allocator, + const CxAllocator *allocator, cx_compare_func comparator, size_t elem_size, size_t initial_capacity
--- a/src/buffer.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/buffer.c Sat Sep 28 15:47:28 2024 +0200 @@ -36,7 +36,7 @@ CxBuffer *buffer, void *space, size_t capacity, - CxAllocator const *allocator, + const CxAllocator *allocator, int flags ) { if (allocator == NULL) allocator = cxDefaultAllocator; @@ -73,7 +73,7 @@ CxBuffer *cxBufferCreate( void *space, size_t capacity, - CxAllocator const *allocator, + const CxAllocator *allocator, int flags ) { CxBuffer *buf = cxMalloc(allocator, sizeof(CxBuffer)); @@ -140,7 +140,7 @@ buffer->pos = 0; } -int cxBufferEof(CxBuffer const *buffer) { +int cxBufferEof(const CxBuffer *buffer) { return buffer->pos >= buffer->size; } @@ -172,7 +172,7 @@ */ static size_t cx_buffer_write_flush_helper( CxBuffer *buffer, - unsigned char const *space, + const unsigned char *space, size_t size, size_t nitems ) { @@ -197,7 +197,7 @@ } size_t cxBufferWrite( - void const *ptr, + const void *ptr, size_t size, size_t nitems, CxBuffer *buffer @@ -273,7 +273,7 @@ items_keep = nitems - items_flush; if (items_keep > 0) { // try again with the remaining stuff - unsigned char const *new_ptr = ptr; + const unsigned char *new_ptr = ptr; new_ptr += items_flush * size; // report the directly flushed items as written plus the remaining stuff return items_flush + cxBufferWrite(new_ptr, size, items_keep, buffer);
--- a/src/compare.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/compare.c Sat Sep 28 15:47:28 2024 +0200 @@ -30,7 +30,7 @@ #include <math.h> -int cx_cmp_int(void const *i1, void const *i2) { +int cx_cmp_int(const void *i1, const void *i2) { int a = *((const int *) i1); int b = *((const int *) i2); if (a == b) { @@ -40,7 +40,7 @@ } } -int cx_cmp_longint(void const *i1, void const *i2) { +int cx_cmp_longint(const void *i1, const void *i2) { long int a = *((const long int *) i1); long int b = *((const long int *) i2); if (a == b) { @@ -50,7 +50,7 @@ } } -int cx_cmp_longlong(void const *i1, void const *i2) { +int cx_cmp_longlong(const void *i1, const void *i2) { long long a = *((const long long *) i1); long long b = *((const long long *) i2); if (a == b) { @@ -60,7 +60,7 @@ } } -int cx_cmp_int16(void const *i1, void const *i2) { +int cx_cmp_int16(const void *i1, const void *i2) { int16_t a = *((const int16_t *) i1); int16_t b = *((const int16_t *) i2); if (a == b) { @@ -70,7 +70,7 @@ } } -int cx_cmp_int32(void const *i1, void const *i2) { +int cx_cmp_int32(const void *i1, const void *i2) { int32_t a = *((const int32_t *) i1); int32_t b = *((const int32_t *) i2); if (a == b) { @@ -80,7 +80,7 @@ } } -int cx_cmp_int64(void const *i1, void const *i2) { +int cx_cmp_int64(const void *i1, const void *i2) { int64_t a = *((const int64_t *) i1); int64_t b = *((const int64_t *) i2); if (a == b) { @@ -90,7 +90,7 @@ } } -int cx_cmp_uint(void const *i1, void const *i2) { +int cx_cmp_uint(const void *i1, const void *i2) { unsigned int a = *((const unsigned int *) i1); unsigned int b = *((const unsigned int *) i2); if (a == b) { @@ -100,7 +100,7 @@ } } -int cx_cmp_ulongint(void const *i1, void const *i2) { +int cx_cmp_ulongint(const void *i1, const void *i2) { unsigned long int a = *((const unsigned long int *) i1); unsigned long int b = *((const unsigned long int *) i2); if (a == b) { @@ -110,7 +110,7 @@ } } -int cx_cmp_ulonglong(void const *i1, void const *i2) { +int cx_cmp_ulonglong(const void *i1, const void *i2) { unsigned long long a = *((const unsigned long long *) i1); unsigned long long b = *((const unsigned long long *) i2); if (a == b) { @@ -120,7 +120,7 @@ } } -int cx_cmp_uint16(void const *i1, void const *i2) { +int cx_cmp_uint16(const void *i1, const void *i2) { uint16_t a = *((const uint16_t *) i1); uint16_t b = *((const uint16_t *) i2); if (a == b) { @@ -130,7 +130,7 @@ } } -int cx_cmp_uint32(void const *i1, void const *i2) { +int cx_cmp_uint32(const void *i1, const void *i2) { uint32_t a = *((const uint32_t *) i1); uint32_t b = *((const uint32_t *) i2); if (a == b) { @@ -140,7 +140,7 @@ } } -int cx_cmp_uint64(void const *i1, void const *i2) { +int cx_cmp_uint64(const void *i1, const void *i2) { uint64_t a = *((const uint64_t *) i1); uint64_t b = *((const uint64_t *) i2); if (a == b) { @@ -150,7 +150,7 @@ } } -int cx_cmp_float(void const *f1, void const *f2) { +int cx_cmp_float(const void *f1, const void *f2) { float a = *((const float *) f1); float b = *((const float *) f2); if (fabsf(a - b) < 1e-6f) { @@ -161,8 +161,8 @@ } int cx_cmp_double( - void const *d1, - void const *d2 + const void *d1, + const void *d2 ) { double a = *((const double *) d1); double b = *((const double *) d2); @@ -174,8 +174,8 @@ } int cx_cmp_intptr( - void const *ptr1, - void const *ptr2 + const void *ptr1, + const void *ptr2 ) { intptr_t p1 = *(const intptr_t *) ptr1; intptr_t p2 = *(const intptr_t *) ptr2; @@ -187,8 +187,8 @@ } int cx_cmp_uintptr( - void const *ptr1, - void const *ptr2 + const void *ptr1, + const void *ptr2 ) { uintptr_t p1 = *(const uintptr_t *) ptr1; uintptr_t p2 = *(const uintptr_t *) ptr2; @@ -200,8 +200,8 @@ } int cx_cmp_ptr( - void const *ptr1, - void const *ptr2 + const void *ptr1, + const void *ptr2 ) { uintptr_t p1 = (uintptr_t) ptr1; uintptr_t p2 = (uintptr_t) ptr2;
--- a/src/cx/allocator.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/allocator.h Sat Sep 28 15:47:28 2024 +0200 @@ -156,7 +156,7 @@ * @return a pointer to the allocated memory */ void *cxMalloc( - CxAllocator const *allocator, + const CxAllocator *allocator, size_t n ) __attribute__((__malloc__)) @@ -175,7 +175,7 @@ * @return a pointer to the re-allocated memory */ void *cxRealloc( - CxAllocator const *allocator, + const CxAllocator *allocator, void *mem, size_t n ) @@ -197,7 +197,7 @@ * @return zero on success, non-zero on failure */ int cxReallocate( - CxAllocator const *allocator, + const CxAllocator *allocator, void **mem, size_t n ) @@ -212,7 +212,7 @@ * @return a pointer to the allocated memory */ void *cxCalloc( - CxAllocator const *allocator, + const CxAllocator *allocator, size_t nelem, size_t n ) @@ -228,7 +228,7 @@ * @param mem a pointer to the block to free */ void cxFree( - CxAllocator const *allocator, + const CxAllocator *allocator, void *mem ) __attribute__((__nonnull__));
--- a/src/cx/array_list.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/array_list.h Sat Sep 28 15:47:28 2024 +0200 @@ -164,7 +164,7 @@ size_t *size, size_t *capacity, size_t index, - void const *src, + const void *src, size_t elem_size, size_t elem_count, struct cx_array_reallocator_s *reallocator @@ -241,7 +241,7 @@ size_t *size, size_t *capacity, cx_compare_func cmp_func, - void const *src, + const void *src, size_t elem_size, size_t elem_count, struct cx_array_reallocator_s *reallocator @@ -316,10 +316,10 @@ * @return the index of the largest lower bound, or \p size */ size_t cx_array_binary_search_inf( - void const *arr, + const void *arr, size_t size, size_t elem_size, - void const *elem, + const void *elem, cx_compare_func cmp_func ) __attribute__((__nonnull__)); @@ -339,16 +339,16 @@ */ __attribute__((__nonnull__)) static inline size_t cx_array_binary_search( - void const *arr, + const void *arr, size_t size, size_t elem_size, - void const *elem, + const void *elem, cx_compare_func cmp_func ) { size_t index = cx_array_binary_search_inf( arr, size, elem_size, elem, cmp_func ); - if (index < size && cmp_func(((char const *) arr) + index * elem_size, elem) == 0) { + if (index < size && cmp_func(((const char *) arr) + index * elem_size, elem) == 0) { return index; } else { return size; @@ -377,17 +377,17 @@ */ __attribute__((__nonnull__)) static inline size_t cx_array_binary_search_sup( - void const *arr, + const void *arr, size_t size, size_t elem_size, - void const *elem, + const void *elem, cx_compare_func cmp_func ) { size_t inf = cx_array_binary_search_inf(arr, size, elem_size, elem, cmp_func); if (inf == size) { // no infimum means, first element is supremum return 0; - } else if (cmp_func(((char const *) arr) + inf * elem_size, elem) == 0) { + } else if (cmp_func(((const char *) arr) + inf * elem_size, elem) == 0) { return inf; } else { return inf + 1; @@ -426,7 +426,7 @@ * @return the created list */ CxList *cxArrayListCreate( - CxAllocator const *allocator, + const CxAllocator *allocator, cx_compare_func comparator, size_t elem_size, size_t initial_capacity
--- a/src/cx/buffer.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/buffer.h Sat Sep 28 15:47:28 2024 +0200 @@ -82,7 +82,7 @@ unsigned char *bytes; }; /** The allocator to use for automatic memory management. */ - CxAllocator const *allocator; + const CxAllocator *allocator; /** Current position of the buffer. */ size_t pos; /** Current capacity (i.e. maximum size) of the buffer. */ @@ -158,7 +158,7 @@ CxBuffer *buffer, void *space, size_t capacity, - CxAllocator const *allocator, + const CxAllocator *allocator, int flags ); @@ -180,7 +180,7 @@ CxBuffer *cxBufferCreate( void *space, size_t capacity, - CxAllocator const *allocator, + const CxAllocator *allocator, int flags ); @@ -339,7 +339,7 @@ * byte of the buffer's contents. */ __attribute__((__nonnull__)) -int cxBufferEof(CxBuffer const *buffer); +int cxBufferEof(const CxBuffer *buffer); /** @@ -385,7 +385,7 @@ */ __attribute__((__nonnull__)) size_t cxBufferWrite( - void const *ptr, + const void *ptr, size_t size, size_t nitems, CxBuffer *buffer
--- a/src/cx/collection.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/collection.h Sat Sep 28 15:47:28 2024 +0200 @@ -56,7 +56,7 @@ /** * The allocator to use. */ - CxAllocator const *allocator; + const CxAllocator *allocator; /** * The comparator function for the elements. */
--- a/src/cx/common.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/common.h Sat Sep 28 15:47:28 2024 +0200 @@ -101,7 +101,7 @@ * Function pointer compatible with fwrite-like functions. */ typedef size_t (*cx_write_func)( - void const *, + const void *, size_t, size_t, void *
--- a/src/cx/compare.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/compare.h Sat Sep 28 15:47:28 2024 +0200 @@ -48,8 +48,8 @@ * A comparator function comparing two collection elements. */ typedef int(*cx_compare_func)( - void const *left, - void const *right + const void *left, + const void *right ); #endif // CX_COMPARE_FUNC_DEFINED @@ -61,7 +61,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_int(void const *i1, void const *i2); +int cx_cmp_int(const void *i1, const void *i2); /** * Compares two integers of type long int. @@ -71,7 +71,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_longint(void const *i1, void const *i2); +int cx_cmp_longint(const void *i1, const void *i2); /** * Compares two integers of type long long. @@ -81,7 +81,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_longlong(void const *i1, void const *i2); +int cx_cmp_longlong(const void *i1, const void *i2); /** * Compares two integers of type int16_t. @@ -91,7 +91,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_int16(void const *i1, void const *i2); +int cx_cmp_int16(const void *i1, const void *i2); /** * Compares two integers of type int32_t. @@ -101,7 +101,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_int32(void const *i1, void const *i2); +int cx_cmp_int32(const void *i1, const void *i2); /** * Compares two integers of type int64_t. @@ -111,7 +111,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_int64(void const *i1, void const *i2); +int cx_cmp_int64(const void *i1, const void *i2); /** * Compares two integers of type unsigned int. @@ -121,7 +121,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_uint(void const *i1, void const *i2); +int cx_cmp_uint(const void *i1, const void *i2); /** * Compares two integers of type unsigned long int. @@ -131,7 +131,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_ulongint(void const *i1, void const *i2); +int cx_cmp_ulongint(const void *i1, const void *i2); /** * Compares two integers of type unsigned long long. @@ -141,7 +141,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_ulonglong(void const *i1, void const *i2); +int cx_cmp_ulonglong(const void *i1, const void *i2); /** * Compares two integers of type uint16_t. @@ -151,7 +151,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_uint16(void const *i1, void const *i2); +int cx_cmp_uint16(const void *i1, const void *i2); /** * Compares two integers of type uint32_t. @@ -161,7 +161,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_uint32(void const *i1, void const *i2); +int cx_cmp_uint32(const void *i1, const void *i2); /** * Compares two integers of type uint64_t. @@ -171,7 +171,7 @@ * @return -1, if *i1 is less than *i2, 0 if both are equal, * 1 if *i1 is greater than *i2 */ -int cx_cmp_uint64(void const *i1, void const *i2); +int cx_cmp_uint64(const void *i1, const void *i2); /** * Compares two real numbers of type float with precision 1e-6f. @@ -182,7 +182,7 @@ * 1 if *f1 is greater than *f2 */ -int cx_cmp_float(void const *f1, void const *f2); +int cx_cmp_float(const void *f1, const void *f2); /** * Compares two real numbers of type double with precision 1e-14. @@ -193,34 +193,34 @@ * 1 if *d1 is greater than *d2 */ int cx_cmp_double( - void const *d1, - void const *d2 + const void *d1, + const void *d2 ); /** * Compares the integer representation of two pointers. * - * @param ptr1 pointer to pointer one (intptr_t const*) - * @param ptr2 pointer to pointer two (intptr_t const*) + * @param ptr1 pointer to pointer one (const intptr_t*) + * @param ptr2 pointer to pointer two (const intptr_t*) * @return -1 if *ptr1 is less than *ptr2, 0 if both are equal, * 1 if *ptr1 is greater than *ptr2 */ int cx_cmp_intptr( - void const *ptr1, - void const *ptr2 + const void *ptr1, + const void *ptr2 ); /** * Compares the unsigned integer representation of two pointers. * - * @param ptr1 pointer to pointer one (uintptr_t const*) - * @param ptr2 pointer to pointer two (uintptr_t const*) + * @param ptr1 pointer to pointer one (const uintptr_t*) + * @param ptr2 pointer to pointer two (const uintptr_t*) * @return -1 if *ptr1 is less than *ptr2, 0 if both are equal, * 1 if *ptr1 is greater than *ptr2 */ int cx_cmp_uintptr( - void const *ptr1, - void const *ptr2 + const void *ptr1, + const void *ptr2 ); /** @@ -232,8 +232,8 @@ * 1 if ptr1 is greater than ptr2 */ int cx_cmp_ptr( - void const *ptr1, - void const *ptr2 + const void *ptr1, + const void *ptr2 ); #ifdef __cplusplus
--- a/src/cx/hash_key.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/hash_key.h Sat Sep 28 15:47:28 2024 +0200 @@ -46,7 +46,7 @@ /** Internal structure for a key within a hash map. */ struct cx_hash_key_s { /** The key data. */ - void const *data; + const void *data; /** * The key data length. */ @@ -81,7 +81,7 @@ * @return the hash key */ __attribute__((__warn_unused_result__)) -CxHashKey cx_hash_key_str(char const *str); +CxHashKey cx_hash_key_str(const char *str); /** * Computes a hash key from a byte array. @@ -92,7 +92,7 @@ */ __attribute__((__warn_unused_result__)) CxHashKey cx_hash_key_bytes( - unsigned char const *bytes, + const unsigned char *bytes, size_t len ); @@ -109,7 +109,7 @@ */ __attribute__((__warn_unused_result__)) CxHashKey cx_hash_key( - void const *obj, + const void *obj, size_t len );
--- a/src/cx/hash_map.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/hash_map.h Sat Sep 28 15:47:28 2024 +0200 @@ -83,7 +83,7 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) CxMap *cxHashMapCreate( - CxAllocator const *allocator, + const CxAllocator *allocator, size_t itemsize, size_t buckets );
--- a/src/cx/iterator.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/iterator.h Sat Sep 28 15:47:28 2024 +0200 @@ -43,7 +43,7 @@ * True iff the iterator points to valid data. */ __attribute__ ((__nonnull__)) - bool (*valid)(void const *); + bool (*valid)(const void *); /** * Returns a pointer to the current element. @@ -51,13 +51,13 @@ * When valid returns false, the behavior of this function is undefined. */ __attribute__ ((__nonnull__)) - void *(*current)(void const *); + void *(*current)(const void *); /** * Original implementation in case the function needs to be wrapped. */ __attribute__ ((__nonnull__)) - void *(*current_impl)(void const *); + void *(*current_impl)(const void *); /** * Advances the iterator. @@ -104,7 +104,7 @@ /** * Access for normal iterators. */ - void const *c; + const void *c; } src_handle; /** @@ -115,7 +115,7 @@ /** * A pointer to the key. */ - void const *key; + const void *key; /** * A pointer to the value. */ @@ -226,7 +226,7 @@ */ __attribute__((__warn_unused_result__)) CxIterator cxIterator( - void const *array, + const void *array, size_t elem_size, size_t elem_count );
--- a/src/cx/linked_list.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/linked_list.h Sat Sep 28 15:47:28 2024 +0200 @@ -65,7 +65,7 @@ * @return the created list */ CxList *cxLinkedListCreate( - CxAllocator const *allocator, + const CxAllocator *allocator, cx_compare_func comparator, size_t elem_size ); @@ -105,7 +105,7 @@ * @return the node found at the specified index */ void *cx_linked_list_at( - void const *start, + const void *start, size_t start_index, ptrdiff_t loc_advance, size_t index @@ -122,11 +122,11 @@ * @return the index of the element or a negative value if it could not be found */ ssize_t cx_linked_list_find( - void const *start, + const void *start, ptrdiff_t loc_advance, ptrdiff_t loc_data, cx_compare_func cmp_func, - void const *elem + const void *elem ) __attribute__((__nonnull__)); /** @@ -143,11 +143,11 @@ */ ssize_t cx_linked_list_find_node( void **result, - void const *start, + const void *start, ptrdiff_t loc_advance, ptrdiff_t loc_data, cx_compare_func cmp_func, - void const *elem + const void *elem ) __attribute__((__nonnull__)); /** @@ -162,7 +162,7 @@ * @return a pointer to the first node */ void *cx_linked_list_first( - void const *node, + const void *node, ptrdiff_t loc_prev ) __attribute__((__nonnull__)); @@ -178,7 +178,7 @@ * @return a pointer to the last node */ void *cx_linked_list_last( - void const *node, + const void *node, ptrdiff_t loc_next ) __attribute__((__nonnull__)); @@ -193,9 +193,9 @@ * @return the node or \c NULL if \p node has no predecessor */ void *cx_linked_list_prev( - void const *begin, + const void *begin, ptrdiff_t loc_next, - void const *node + const void *node ) __attribute__((__nonnull__)); /** @@ -409,7 +409,7 @@ * @return the size of the list or zero if \p node is \c NULL */ size_t cx_linked_list_size( - void const *node, + const void *node, ptrdiff_t loc_next ); @@ -459,8 +459,8 @@ * right list, positive if the left list is larger than the right list, zero if both lists are equal. */ int cx_linked_list_compare( - void const *begin_left, - void const *begin_right, + const void *begin_left, + const void *begin_right, ptrdiff_t loc_advance, ptrdiff_t loc_data, cx_compare_func cmp_func
--- a/src/cx/list.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/list.h Sat Sep 28 15:47:28 2024 +0200 @@ -56,11 +56,11 @@ /** * The list class definition. */ - cx_list_class const *cl; + const cx_list_class *cl; /** * The actual implementation in case the list class is delegating. */ - cx_list_class const *climpl; + const cx_list_class *climpl; }; /** @@ -82,7 +82,7 @@ int (*insert_element)( struct cx_list_s *list, size_t index, - void const *data + const void *data ); /** @@ -93,7 +93,7 @@ size_t (*insert_array)( struct cx_list_s *list, size_t index, - void const *data, + const void *data, size_t n ); @@ -104,7 +104,7 @@ */ size_t (*insert_sorted)( struct cx_list_s *list, - void const *sorted_data, + const void *sorted_data, size_t n ); @@ -113,7 +113,7 @@ */ int (*insert_iter)( struct cx_iterator_s *iter, - void const *elem, + const void *elem, int prepend ); @@ -144,7 +144,7 @@ * Member function for element lookup. */ void *(*at)( - struct cx_list_s const *list, + const struct cx_list_s *list, size_t index ); @@ -153,7 +153,7 @@ */ ssize_t (*find_remove)( struct cx_list_s *list, - void const *elem, + const void *elem, bool remove ); @@ -169,8 +169,8 @@ * If set to \c NULL, comparison won't be optimized. */ int (*compare)( - struct cx_list_s const *list, - struct cx_list_s const *other + const struct cx_list_s *list, + const struct cx_list_s *other ); /** @@ -182,7 +182,7 @@ * Member function for returning an iterator pointing to the specified index. */ struct cx_iterator_s (*iterator)( - struct cx_list_s const *list, + const struct cx_list_s *list, size_t index, bool backward ); @@ -206,7 +206,7 @@ size_t cx_list_default_insert_array( struct cx_list_s *list, size_t index, - void const *data, + const void *data, size_t n ); @@ -229,7 +229,7 @@ __attribute__((__nonnull__)) size_t cx_list_default_insert_sorted( struct cx_list_s *list, - void const *sorted_data, + const void *sorted_data, size_t n ); @@ -302,7 +302,7 @@ * @see cxListStorePointers() */ __attribute__((__nonnull__)) -static inline bool cxListIsStoringPointers(CxList const *list) { +static inline bool cxListIsStoringPointers(const CxList *list) { return list->collection.store_pointer; } @@ -313,7 +313,7 @@ * @return the number of currently stored elements */ __attribute__((__nonnull__)) -static inline size_t cxListSize(CxList const *list) { +static inline size_t cxListSize(const CxList *list) { return list->collection.size; } @@ -328,7 +328,7 @@ __attribute__((__nonnull__)) static inline int cxListAdd( CxList *list, - void const *elem + const void *elem ) { return list->cl->insert_element(list, list->collection.size, elem); } @@ -352,7 +352,7 @@ __attribute__((__nonnull__)) static inline size_t cxListAddArray( CxList *list, - void const *array, + const void *array, size_t n ) { return list->cl->insert_array(list, list->collection.size, array, n); @@ -375,7 +375,7 @@ static inline int cxListInsert( CxList *list, size_t index, - void const *elem + const void *elem ) { return list->cl->insert_element(list, index, elem); } @@ -390,9 +390,9 @@ __attribute__((__nonnull__)) static inline int cxListInsertSorted( CxList *list, - void const *elem + const void *elem ) { - void const *data = list->collection.store_pointer ? &elem : elem; + const void *data = list->collection.store_pointer ? &elem : elem; return list->cl->insert_sorted(list, data, 1) == 0; } @@ -419,7 +419,7 @@ static inline size_t cxListInsertArray( CxList *list, size_t index, - void const *array, + const void *array, size_t n ) { return list->cl->insert_array(list, index, array, n); @@ -445,7 +445,7 @@ __attribute__((__nonnull__)) static inline size_t cxListInsertSortedArray( CxList *list, - void const *array, + const void *array, size_t n ) { return list->cl->insert_sorted(list, array, n); @@ -469,7 +469,7 @@ __attribute__((__nonnull__)) static inline int cxListInsertAfter( CxIterator *iter, - void const *elem + const void *elem ) { return ((struct cx_list_s *) iter->src_handle.m)->cl->insert_iter(iter, elem, 0); } @@ -492,7 +492,7 @@ __attribute__((__nonnull__)) static inline int cxListInsertBefore( CxIterator *iter, - void const *elem + const void *elem ) { return ((struct cx_list_s *) iter->src_handle.m)->cl->insert_iter(iter, elem, 1); } @@ -576,7 +576,7 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) static inline CxIterator cxListIteratorAt( - CxList const *list, + const CxList *list, size_t index ) { return list->cl->iterator(list, index, false); @@ -595,7 +595,7 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) static inline CxIterator cxListBackwardsIteratorAt( - CxList const *list, + const CxList *list, size_t index ) { return list->cl->iterator(list, index, true); @@ -647,7 +647,7 @@ * @return a new iterator */ __attribute__((__nonnull__, __warn_unused_result__)) -static inline CxIterator cxListIterator(CxList const *list) { +static inline CxIterator cxListIterator(const CxList *list) { return list->cl->iterator(list, 0, false); } @@ -678,7 +678,7 @@ * @return a new iterator */ __attribute__((__nonnull__, __warn_unused_result__)) -static inline CxIterator cxListBackwardsIterator(CxList const *list) { +static inline CxIterator cxListBackwardsIterator(const CxList *list) { return list->cl->iterator(list, list->collection.size - 1, true); } @@ -709,8 +709,8 @@ */ __attribute__((__nonnull__)) static inline ssize_t cxListFind( - CxList const *list, - void const *elem + const CxList *list, + const void *elem ) { return list->cl->find_remove((CxList*)list, elem, false); } @@ -728,7 +728,7 @@ __attribute__((__nonnull__)) static inline ssize_t cxListFindRemove( CxList *list, - void const *elem + const void *elem ) { return list->cl->find_remove(list, elem, true); } @@ -768,8 +768,8 @@ */ __attribute__((__nonnull__)) int cxListCompare( - CxList const *list, - CxList const *other + const CxList *list, + const CxList *other ); /**
--- a/src/cx/map.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/map.h Sat Sep 28 15:47:28 2024 +0200 @@ -113,7 +113,7 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) void *(*get)( - CxMap const *map, + const CxMap *map, CxHashKey key ); @@ -131,7 +131,7 @@ * Creates an iterator for this map. */ __attribute__((__nonnull__, __warn_unused_result__)) - CxIterator (*iterator)(CxMap const *map, enum cx_map_iterator_type type); + CxIterator (*iterator)(const CxMap *map, enum cx_map_iterator_type type); }; /** @@ -141,7 +141,7 @@ /** * A pointer to the key. */ - CxHashKey const *key; + const CxHashKey *key; /** * A pointer to the value. */ @@ -195,7 +195,7 @@ * @see cxMapStorePointers() */ __attribute__((__nonnull__)) -static inline bool cxMapIsStoringPointers(CxMap const *map) { +static inline bool cxMapIsStoringPointers(const CxMap *map) { return map->collection.store_pointer; } @@ -227,7 +227,7 @@ * @return the number of stored elements */ __attribute__((__nonnull__)) -static inline size_t cxMapSize(CxMap const *map) { +static inline size_t cxMapSize(const CxMap *map) { return map->collection.size; } @@ -244,7 +244,7 @@ * @return an iterator for the currently stored values */ __attribute__((__nonnull__, __warn_unused_result__)) -static inline CxIterator cxMapIteratorValues(CxMap const *map) { +static inline CxIterator cxMapIteratorValues(const CxMap *map) { return map->cl->iterator(map, CX_MAP_ITERATOR_VALUES); } @@ -260,7 +260,7 @@ * @return an iterator for the currently stored keys */ __attribute__((__nonnull__, __warn_unused_result__)) -static inline CxIterator cxMapIteratorKeys(CxMap const *map) { +static inline CxIterator cxMapIteratorKeys(const CxMap *map) { return map->cl->iterator(map, CX_MAP_ITERATOR_KEYS); } @@ -278,7 +278,7 @@ * @see cxMapIteratorValues() */ __attribute__((__nonnull__, __warn_unused_result__)) -static inline CxIterator cxMapIterator(CxMap const *map) { +static inline CxIterator cxMapIterator(const CxMap *map) { return map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS); } @@ -391,7 +391,7 @@ __attribute__((__nonnull__)) static inline int cxMapPut( CxMap *map, - char const *key, + const char *key, void *value ) { return map->cl->put(map, cx_hash_key_str(key), value); @@ -406,7 +406,7 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) static inline void *cxMapGet( - CxMap const *map, + const CxMap *map, CxHashKey const &key ) { return map->cl->get(map, key); @@ -421,7 +421,7 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) static inline void *cxMapGet( - CxMap const *map, + const CxMap *map, cxstring const &key ) { return map->cl->get(map, cx_hash_key_cxstr(key)); @@ -436,7 +436,7 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) static inline void *cxMapGet( - CxMap const *map, + const CxMap *map, cxmutstr const &key ) { return map->cl->get(map, cx_hash_key_cxstr(key)); @@ -451,8 +451,8 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) static inline void *cxMapGet( - CxMap const *map, - char const *key + const CxMap *map, + const char *key ) { return map->cl->get(map, cx_hash_key_str(key)); } @@ -540,7 +540,7 @@ __attribute__((__nonnull__)) static inline void cxMapRemove( CxMap *map, - char const *key + const char *key ) { (void) map->cl->remove(map, cx_hash_key_str(key), true); } @@ -628,7 +628,7 @@ __attribute__((__nonnull__)) static inline void cxMapDetach( CxMap *map, - char const *key + const char *key ) { (void) map->cl->remove(map, cx_hash_key_str(key), false); } @@ -736,7 +736,7 @@ __attribute__((__nonnull__, __warn_unused_result__)) static inline void *cxMapRemoveAndGet( CxMap *map, - char const *key + const char *key ) { return map->cl->remove(map, cx_hash_key_str(key), !map->store_pointer); } @@ -805,7 +805,7 @@ __attribute__((__nonnull__)) static inline int cx_map_put_str( CxMap *map, - char const *key, + const char *key, void *value ) { return map->cl->put(map, cx_hash_key_str(key), value); @@ -824,7 +824,7 @@ cxstring: cx_map_put_cxstr, \ cxmutstr: cx_map_put_mustr, \ char*: cx_map_put_str, \ - char const*: cx_map_put_str) \ + const char*: cx_map_put_str) \ (map, key, value) /** @@ -836,7 +836,7 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) static inline void *cx_map_get( - CxMap const *map, + const CxMap *map, CxHashKey key ) { return map->cl->get(map, key); @@ -851,7 +851,7 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) static inline void *cx_map_get_cxstr( - CxMap const *map, + const CxMap *map, cxstring key ) { return map->cl->get(map, cx_hash_key_cxstr(key)); @@ -866,7 +866,7 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) static inline void *cx_map_get_mustr( - CxMap const *map, + const CxMap *map, cxmutstr key ) { return map->cl->get(map, cx_hash_key_cxstr(key)); @@ -881,8 +881,8 @@ */ __attribute__((__nonnull__, __warn_unused_result__)) static inline void *cx_map_get_str( - CxMap const *map, - char const *key + const CxMap *map, + const char *key ) { return map->cl->get(map, cx_hash_key_str(key)); } @@ -899,7 +899,7 @@ cxstring: cx_map_get_cxstr, \ cxmutstr: cx_map_get_mustr, \ char*: cx_map_get_str, \ - char const*: cx_map_get_str) \ + const char*: cx_map_get_str) \ (map, key) /** @@ -953,7 +953,7 @@ __attribute__((__nonnull__)) static inline void cx_map_remove_str( CxMap *map, - char const *key + const char *key ) { (void) map->cl->remove(map, cx_hash_key_str(key), true); } @@ -977,7 +977,7 @@ cxstring: cx_map_remove_cxstr, \ cxmutstr: cx_map_remove_mustr, \ char*: cx_map_remove_str, \ - char const*: cx_map_remove_str) \ + const char*: cx_map_remove_str) \ (map, key) /** @@ -1035,7 +1035,7 @@ __attribute__((__nonnull__)) static inline void cx_map_detach_str( CxMap *map, - char const *key + const char *key ) { (void) map->cl->remove(map, cx_hash_key_str(key), false); } @@ -1059,7 +1059,7 @@ cxstring: cx_map_detach_cxstr, \ cxmutstr: cx_map_detach_mustr, \ char*: cx_map_detach_str, \ - char const*: cx_map_detach_str) \ + const char*: cx_map_detach_str) \ (map, key) /** @@ -1121,7 +1121,7 @@ __attribute__((__nonnull__, __warn_unused_result__)) static inline void *cx_map_remove_and_get_str( CxMap *map, - char const *key + const char *key ) { return map->cl->remove(map, cx_hash_key_str(key), !map->collection.store_pointer); } @@ -1150,7 +1150,7 @@ cxstring: cx_map_remove_and_get_cxstr, \ cxmutstr: cx_map_remove_and_get_mustr, \ char*: cx_map_remove_and_get_str, \ - char const*: cx_map_remove_and_get_str) \ + const char*: cx_map_remove_and_get_str) \ (map, key) #endif // __cplusplus
--- a/src/cx/mempool.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/mempool.h Sat Sep 28 15:47:28 2024 +0200 @@ -52,7 +52,7 @@ */ struct cx_mempool_s { /** The provided allocator. */ - CxAllocator const *allocator; + const CxAllocator *allocator; /** * A destructor that shall be automatically registered for newly allocated memory.
--- a/src/cx/printf.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/printf.h Sat Sep 28 15:47:28 2024 +0200 @@ -64,7 +64,7 @@ int cx_fprintf( void *stream, cx_write_func wfc, - char const *fmt, + const char *fmt, ... ); @@ -83,7 +83,7 @@ int cx_vfprintf( void *stream, cx_write_func wfc, - char const *fmt, + const char *fmt, va_list ap ); @@ -101,8 +101,8 @@ */ __attribute__((__nonnull__(1, 2), __format__(printf, 2, 3))) cxmutstr cx_asprintf_a( - CxAllocator const *allocator, - char const *fmt, + const CxAllocator *allocator, + const char *fmt, ... ); @@ -134,8 +134,8 @@ */ __attribute__((__nonnull__)) cxmutstr cx_vasprintf_a( - CxAllocator const *allocator, - char const *fmt, + const CxAllocator *allocator, + const char *fmt, va_list ap );
--- a/src/cx/string.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/string.h Sat Sep 28 15:47:28 2024 +0200 @@ -72,7 +72,7 @@ * \note The string is not necessarily \c NULL terminated. * Always use the length. */ - char const *ptr; + const char *ptr; /** The length of the string */ size_t length; }; @@ -97,7 +97,7 @@ /** * Optional array of more delimiters. */ - cxstring const *delim_more; + const cxstring *delim_more; /** * Length of the array containing more delimiters. */ @@ -213,7 +213,7 @@ * @see cx_strn() */ __attribute__((__warn_unused_result__, __nonnull__)) -cxstring cx_str(char const *cstring); +cxstring cx_str(const char *cstring); /** @@ -234,7 +234,7 @@ */ __attribute__((__warn_unused_result__)) cxstring cx_strn( - char const *cstring, + const char *cstring, size_t length ); @@ -257,8 +257,8 @@ * The pointer in the struct is set to \c NULL and the length is set to zero. * * \note There is no implementation for cxstring, because it is unlikely that - * you ever have a \c char \c const* you are really supposed to free. If you - * encounter such situation, you should double-check your code. + * you ever have a <code>const char*</code> you are really supposed to free. + * If you encounter such situation, you should double-check your code. * * @param str the string to free */ @@ -271,15 +271,15 @@ * The pointer in the struct is set to \c NULL and the length is set to zero. * * \note There is no implementation for cxstring, because it is unlikely that - * you ever have a \c char \c const* you are really supposed to free. If you - * encounter such situation, you should double-check your code. + * you ever have a <code>const char*</code> you are really supposed to free. + * If you encounter such situation, you should double-check your code. * * @param alloc the allocator * @param str the string to free */ __attribute__((__nonnull__)) void cx_strfree_a( - CxAllocator const *alloc, + const CxAllocator *alloc, cxmutstr *str ); @@ -319,7 +319,7 @@ */ __attribute__((__warn_unused_result__, __nonnull__)) cxmutstr cx_strcat_ma( - CxAllocator const *alloc, + const CxAllocator *alloc, cxmutstr str, size_t count, ... @@ -629,7 +629,7 @@ */ __attribute__((__warn_unused_result__, __nonnull__)) size_t cx_strsplit_a( - CxAllocator const *allocator, + const CxAllocator *allocator, cxstring string, cxstring delim, size_t limit, @@ -678,7 +678,7 @@ */ __attribute__((__warn_unused_result__, __nonnull__)) size_t cx_strsplit_ma( - CxAllocator const *allocator, + const CxAllocator *allocator, cxmutstr string, cxstring delim, size_t limit, @@ -725,8 +725,8 @@ */ __attribute__((__warn_unused_result__, __nonnull__)) int cx_strcmp_p( - void const *s1, - void const *s2 + const void *s1, + const void *s2 ); /** @@ -741,8 +741,8 @@ */ __attribute__((__warn_unused_result__, __nonnull__)) int cx_strcasecmp_p( - void const *s1, - void const *s2 + const void *s1, + const void *s2 ); @@ -760,7 +760,7 @@ */ __attribute__((__warn_unused_result__, __nonnull__)) cxmutstr cx_strdup_a( - CxAllocator const *allocator, + const CxAllocator *allocator, cxstring string ); @@ -928,7 +928,7 @@ */ __attribute__((__warn_unused_result__, __nonnull__)) cxmutstr cx_strreplacen_a( - CxAllocator const *allocator, + const CxAllocator *allocator, cxstring str, cxstring pattern, cxstring replacement, @@ -1070,7 +1070,7 @@ __attribute__((__nonnull__)) void cx_strtok_delim( CxStrtokCtx *ctx, - cxstring const *delim, + const cxstring *delim, size_t count );
--- a/src/cx/test.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/test.h Sat Sep 28 15:47:28 2024 +0200 @@ -96,7 +96,7 @@ * Function pointer compatible with fwrite-like functions. */ typedef size_t (*cx_write_func)( - void const *, + const void *, size_t, size_t, void * @@ -134,7 +134,7 @@ unsigned int failure; /** The optional name of this test suite. */ - char const *name; + const char *name; /** * Internal list of test cases. @@ -148,7 +148,7 @@ * @param name optional name of the suite * @return a new test suite */ -static inline CxTestSuite* cx_test_suite_new(char const *name) { +static inline CxTestSuite* cx_test_suite_new(const char *name) { CxTestSuite* suite = (CxTestSuite*) malloc(sizeof(CxTestSuite)); if (suite != NULL) { suite->name = name; @@ -276,7 +276,7 @@ * @param message the message that shall be printed out on failure */ #define CX_TEST_ASSERTM(condition,message) if (!(condition)) { \ - char const* _assert_msg_ = message; \ + const char *_assert_msg_ = message; \ _writefnc_(_assert_msg_, 1, strlen(_assert_msg_), _output_); \ _writefnc_(".\n", 1, 2, _output_); \ _suite_->failure++; \
--- a/src/cx/tree.h Wed Sep 18 00:02:18 2024 +0200 +++ b/src/cx/tree.h Sat Sep 28 15:47:28 2024 +0200 @@ -321,7 +321,7 @@ * positive if one of the children might contain the data, * negative if neither the node, nor the children contains the data */ -typedef int (*cx_tree_search_data_func)(void const *node, void const *data); +typedef int (*cx_tree_search_data_func)(const void *node, const void *data); /** @@ -348,7 +348,7 @@ * positive if one of the children might contain the data, * negative if neither the node, nor the children contains the data */ -typedef int (*cx_tree_search_func)(void const *node, void const *new_node); +typedef int (*cx_tree_search_func)(const void *node, const void *new_node); /** * Searches for data in a tree. @@ -375,8 +375,8 @@ */ __attribute__((__nonnull__)) int cx_tree_search_data( - void const *root, - void const *data, + const void *root, + const void *data, cx_tree_search_data_func sfunc, void **result, ptrdiff_t loc_children, @@ -408,8 +408,8 @@ */ __attribute__((__nonnull__)) int cx_tree_search( - void const *root, - void const *node, + const void *root, + const void *node, cx_tree_search_func sfunc, void **result, ptrdiff_t loc_children, @@ -479,7 +479,7 @@ * \note the function may leave the node pointers in the struct uninitialized. * The caller is responsible to set them according to the intended use case. */ -typedef void *(*cx_tree_node_create_func)(void const *, void *); +typedef void *(*cx_tree_node_create_func)(const void *, void *); /** * The local search depth for a new subtree when adding multiple elements. @@ -580,7 +580,7 @@ */ __attribute__((__nonnull__(1, 4, 5, 7, 8))) size_t cx_tree_add_array( - void const *src, + const void *src, size_t num, size_t elem_size, cx_tree_search_func sfunc, @@ -642,7 +642,7 @@ */ __attribute__((__nonnull__(1, 2, 3, 5, 6))) int cx_tree_add( - void const *src, + const void *src, cx_tree_search_func sfunc, cx_tree_node_create_func cfunc, void *cdata,
--- a/src/hash_key.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/hash_key.c Sat Sep 28 15:47:28 2024 +0200 @@ -30,7 +30,7 @@ #include <string.h> void cx_hash_murmur(CxHashKey *key) { - unsigned char const *data = key->data; + const unsigned char *data = key->data; if (data == NULL) { // extension: special value for NULL key->hash = 1574210520u; @@ -81,7 +81,7 @@ key->hash = h; } -CxHashKey cx_hash_key_str(char const *str) { +CxHashKey cx_hash_key_str(const char *str) { CxHashKey key; key.data = str; key.len = str == NULL ? 0 : strlen(str); @@ -90,7 +90,7 @@ } CxHashKey cx_hash_key_bytes( - unsigned char const *bytes, + const unsigned char *bytes, size_t len ) { CxHashKey key; @@ -101,7 +101,7 @@ } CxHashKey cx_hash_key( - void const *obj, + const void *obj, size_t len ) { CxHashKey key;
--- a/src/hash_map.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/hash_map.c Sat Sep 28 15:47:28 2024 +0200 @@ -84,7 +84,7 @@ void *value ) { struct cx_hash_map_s *hash_map = (struct cx_hash_map_s *) map; - CxAllocator const *allocator = map->collection.allocator; + const CxAllocator *allocator = map->collection.allocator; unsigned hash = key.hash; if (hash == 0) { @@ -223,7 +223,7 @@ } static void *cx_hash_map_get( - CxMap const *map, + const CxMap *map, CxHashKey key ) { // we can safely cast, because we know the map stays untouched @@ -238,21 +238,21 @@ return cx_hash_map_get_remove(map, key, true, destroy); } -static void *cx_hash_map_iter_current_entry(void const *it) { - struct cx_iterator_s const *iter = it; +static void *cx_hash_map_iter_current_entry(const void *it) { + const struct cx_iterator_s *iter = it; // struct has to have a compatible signature return (struct cx_map_entry_s *) &(iter->kv_data); } -static void *cx_hash_map_iter_current_key(void const *it) { - struct cx_iterator_s const *iter = it; +static void *cx_hash_map_iter_current_key(const void *it) { + const struct cx_iterator_s *iter = it; struct cx_hash_map_element_s *elm = iter->elem_handle; return &elm->key; } -static void *cx_hash_map_iter_current_value(void const *it) { - struct cx_iterator_s const *iter = it; - struct cx_hash_map_s const *map = iter->src_handle.c; +static void *cx_hash_map_iter_current_value(const void *it) { + const struct cx_iterator_s *iter = it; + const struct cx_hash_map_s *map = iter->src_handle.c; struct cx_hash_map_element_s *elm = iter->elem_handle; if (map->base.collection.store_pointer) { return *(void **) elm->data; @@ -261,8 +261,8 @@ } } -static bool cx_hash_map_iter_valid(void const *it) { - struct cx_iterator_s const *iter = it; +static bool cx_hash_map_iter_valid(const void *it) { + const struct cx_iterator_s *iter = it; return iter->elem_handle != NULL; } @@ -324,7 +324,7 @@ } static CxIterator cx_hash_map_iterator( - CxMap const *map, + const CxMap *map, enum cx_map_iterator_type type ) { CxIterator iter; @@ -389,7 +389,7 @@ }; CxMap *cxHashMapCreate( - CxAllocator const *allocator, + const CxAllocator *allocator, size_t itemsize, size_t buckets ) {
--- a/src/iterator.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/iterator.c Sat Sep 28 15:47:28 2024 +0200 @@ -30,13 +30,13 @@ #include <string.h> -static bool cx_iter_valid(void const *it) { - struct cx_iterator_s const *iter = it; +static bool cx_iter_valid(const void *it) { + const struct cx_iterator_s *iter = it; return iter->index < iter->elem_count; } -static void *cx_iter_current(void const *it) { - struct cx_iterator_s const *iter = it; +static void *cx_iter_current(const void *it) { + const struct cx_iterator_s *iter = it; return iter->elem_handle; } @@ -102,7 +102,7 @@ } CxIterator cxIterator( - void const *array, + const void *array, size_t elem_size, size_t elem_count ) {
--- a/src/linked_list.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/linked_list.c Sat Sep 28 15:47:28 2024 +0200 @@ -41,7 +41,7 @@ #define ll_data(node) (((char*)(node))+loc_data) void *cx_linked_list_at( - void const *start, + const void *start, size_t start_index, ptrdiff_t loc_advance, size_t index @@ -49,7 +49,7 @@ assert(start != NULL); assert(loc_advance >= 0); size_t i = start_index; - void const *cur = start; + const void *cur = start; while (i != index && cur != NULL) { cur = ll_advance(cur); i < index ? i++ : i--; @@ -58,11 +58,11 @@ } ssize_t cx_linked_list_find( - void const *start, + const void *start, ptrdiff_t loc_advance, ptrdiff_t loc_data, cx_compare_func cmp_func, - void const *elem + const void *elem ) { void *dummy; return cx_linked_list_find_node( @@ -74,11 +74,11 @@ ssize_t cx_linked_list_find_node( void **result, - void const *start, + const void *start, ptrdiff_t loc_advance, ptrdiff_t loc_data, cx_compare_func cmp_func, - void const *elem + const void *elem ) { assert(result != NULL); assert(start != NULL); @@ -86,7 +86,7 @@ assert(loc_data >= 0); assert(cmp_func); - void const *node = start; + const void *node = start; ssize_t index = 0; do { void *current = ll_data(node); @@ -102,21 +102,21 @@ } void *cx_linked_list_first( - void const *node, + const void *node, ptrdiff_t loc_prev ) { return cx_linked_list_last(node, loc_prev); } void *cx_linked_list_last( - void const *node, + const void *node, ptrdiff_t loc_next ) { assert(node != NULL); assert(loc_next >= 0); - void const *cur = node; - void const *last; + const void *cur = node; + const void *last; do { last = cur; } while ((cur = ll_next(cur)) != NULL); @@ -125,16 +125,16 @@ } void *cx_linked_list_prev( - void const *begin, + const void *begin, ptrdiff_t loc_next, - void const *node + const void *node ) { assert(begin != NULL); assert(node != NULL); assert(loc_next >= 0); if (begin == node) return NULL; - void const *cur = begin; - void const *next; + const void *cur = begin; + const void *next; while (1) { next = ll_next(cur); if (next == node) return (void *) cur; @@ -376,7 +376,7 @@ } size_t cx_linked_list_size( - void const *node, + const void *node, ptrdiff_t loc_next ) { assert(loc_next >= 0); @@ -514,17 +514,17 @@ } int cx_linked_list_compare( - void const *begin_left, - void const *begin_right, + const void *begin_left, + const void *begin_right, ptrdiff_t loc_advance, ptrdiff_t loc_data, cx_compare_func cmp_func ) { - void const *left = begin_left, *right = begin_right; + const void *left = begin_left, *right = begin_right; while (left != NULL && right != NULL) { - void const *left_data = ll_data(left); - void const *right_data = ll_data(right); + const void *left_data = ll_data(left); + const void *right_data = ll_data(right); int result = cmp_func(left_data, right_data); if (result != 0) return result; left = ll_advance(left); @@ -587,7 +587,7 @@ } cx_linked_list; static cx_linked_list_node *cx_ll_node_at( - cx_linked_list const *list, + const cx_linked_list *list, size_t index ) { if (index >= list->base.collection.size) { @@ -599,7 +599,7 @@ } } -static cx_linked_list_node *cx_ll_malloc_node(struct cx_list_s const *list) { +static cx_linked_list_node *cx_ll_malloc_node(const struct cx_list_s *list) { return cxMalloc(list->collection.allocator, sizeof(cx_linked_list_node) + list->collection.elem_size); } @@ -607,7 +607,7 @@ static int cx_ll_insert_at( struct cx_list_s *list, cx_linked_list_node *node, - void const *elem + const void *elem ) { // create the new new_node @@ -636,7 +636,7 @@ static size_t cx_ll_insert_array( struct cx_list_s *list, size_t index, - void const *array, + const void *array, size_t n ) { // out-of bounds and corner case check @@ -657,7 +657,7 @@ node = node == NULL ? ((cx_linked_list *) list)->begin : node->next; // we can add the remaining nodes and immediately advance to the inserted node - char const *source = array; + const char *source = array; for (size_t i = 1; i < n; i++) { source += list->collection.elem_size; if (0 != cx_ll_insert_at(list, node, source)) { @@ -671,22 +671,22 @@ static int cx_ll_insert_element( struct cx_list_s *list, size_t index, - void const *element + const void *element ) { return 1 != cx_ll_insert_array(list, index, element, 1); } static _Thread_local cx_compare_func cx_ll_insert_sorted_cmp_func; -static int cx_ll_insert_sorted_cmp_helper(void const *l, void const *r) { - cx_linked_list_node const *left = l; - cx_linked_list_node const *right = r; +static int cx_ll_insert_sorted_cmp_helper(const void *l, const void *r) { + const cx_linked_list_node *left = l; + const cx_linked_list_node *right = r; return cx_ll_insert_sorted_cmp_func(left->payload, right->payload); } static size_t cx_ll_insert_sorted( struct cx_list_s *list, - void const *array, + const void *array, size_t n ) { // special case @@ -702,7 +702,7 @@ // add all elements from the array to that chain cx_linked_list_node *prev = chain; - char const *src = array; + const char *src = array; size_t inserted = 1; for (; inserted < n; inserted++) { cx_linked_list_node *next = cx_ll_malloc_node(list); @@ -898,7 +898,7 @@ } static void *cx_ll_at( - struct cx_list_s const *list, + const struct cx_list_s *list, size_t index ) { cx_linked_list *ll = (cx_linked_list *) list; @@ -908,7 +908,7 @@ static ssize_t cx_ll_find_remove( struct cx_list_s *list, - void const *elem, + const void *elem, bool remove ) { if (remove) { @@ -950,8 +950,8 @@ } static int cx_ll_compare( - struct cx_list_s const *list, - struct cx_list_s const *other + const struct cx_list_s *list, + const struct cx_list_s *other ) { cx_linked_list *left = (cx_linked_list *) list; cx_linked_list *right = (cx_linked_list *) other; @@ -960,8 +960,8 @@ list->collection.cmpfunc); } -static bool cx_ll_iter_valid(void const *it) { - struct cx_iterator_s const *iter = it; +static bool cx_ll_iter_valid(const void *it) { + const struct cx_iterator_s *iter = it; return iter->elem_handle != NULL; } @@ -1006,21 +1006,21 @@ } } -static void *cx_ll_iter_current(void const *it) { - struct cx_iterator_s const *iter = it; +static void *cx_ll_iter_current(const void *it) { + const struct cx_iterator_s *iter = it; cx_linked_list_node *node = iter->elem_handle; return node->payload; } static CxIterator cx_ll_iterator( - struct cx_list_s const *list, + const struct cx_list_s *list, size_t index, bool backwards ) { CxIterator iter; iter.index = index; iter.src_handle.c = list; - iter.elem_handle = cx_ll_node_at((cx_linked_list const *) list, index); + iter.elem_handle = cx_ll_node_at((const cx_linked_list *) list, index); iter.elem_size = list->collection.elem_size; iter.elem_count = list->collection.size; iter.base.valid = cx_ll_iter_valid; @@ -1033,7 +1033,7 @@ static int cx_ll_insert_iter( CxIterator *iter, - void const *elem, + const void *elem, int prepend ) { struct cx_list_s *list = iter->src_handle.m; @@ -1091,7 +1091,7 @@ }; CxList *cxLinkedListCreate( - CxAllocator const *allocator, + const CxAllocator *allocator, cx_compare_func comparator, size_t elem_size ) {
--- a/src/list.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/list.c Sat Sep 28 15:47:28 2024 +0200 @@ -35,24 +35,24 @@ static _Thread_local cx_compare_func cx_pl_cmpfunc_impl; static int cx_pl_cmpfunc( - void const *l, - void const *r + const void *l, + const void *r ) { void *const *lptr = l; void *const *rptr = r; - void const *left = lptr == NULL ? NULL : *lptr; - void const *right = rptr == NULL ? NULL : *rptr; + const void *left = lptr == NULL ? NULL : *lptr; + const void *right = rptr == NULL ? NULL : *rptr; return cx_pl_cmpfunc_impl(left, right); } -static void cx_pl_hack_cmpfunc(struct cx_list_s const *list) { +static void cx_pl_hack_cmpfunc(const struct cx_list_s *list) { // cast away const - this is the hacky thing struct cx_collection_s *l = (struct cx_collection_s*) &list->collection; cx_pl_cmpfunc_impl = l->cmpfunc; l->cmpfunc = cx_pl_cmpfunc; } -static void cx_pl_unhack_cmpfunc(struct cx_list_s const *list) { +static void cx_pl_unhack_cmpfunc(const struct cx_list_s *list) { // cast away const - this is the hacky thing struct cx_collection_s *l = (struct cx_collection_s*) &list->collection; l->cmpfunc = cx_pl_cmpfunc_impl; @@ -65,7 +65,7 @@ static int cx_pl_insert_element( struct cx_list_s *list, size_t index, - void const *element + const void *element ) { return list->climpl->insert_element(list, index, &element); } @@ -73,7 +73,7 @@ static size_t cx_pl_insert_array( struct cx_list_s *list, size_t index, - void const *array, + const void *array, size_t n ) { return list->climpl->insert_array(list, index, array, n); @@ -81,7 +81,7 @@ static size_t cx_pl_insert_sorted( struct cx_list_s *list, - void const *array, + const void *array, size_t n ) { cx_pl_hack_cmpfunc(list); @@ -92,7 +92,7 @@ static int cx_pl_insert_iter( struct cx_iterator_s *iter, - void const *elem, + const void *elem, int prepend ) { struct cx_list_s *list = iter->src_handle.m; @@ -119,7 +119,7 @@ } static void *cx_pl_at( - struct cx_list_s const *list, + const struct cx_list_s *list, size_t index ) { void **ptr = list->climpl->at(list, index); @@ -128,7 +128,7 @@ static ssize_t cx_pl_find_remove( struct cx_list_s *list, - void const *elem, + const void *elem, bool remove ) { cx_pl_hack_cmpfunc(list); @@ -144,8 +144,8 @@ } static int cx_pl_compare( - struct cx_list_s const *list, - struct cx_list_s const *other + const struct cx_list_s *list, + const struct cx_list_s *other ) { cx_pl_hack_cmpfunc(list); int ret = list->climpl->compare(list, other); @@ -157,14 +157,14 @@ list->climpl->reverse(list); } -static void *cx_pl_iter_current(void const *it) { - struct cx_iterator_s const *iter = it; +static void *cx_pl_iter_current(const void *it) { + const struct cx_iterator_s *iter = it; void **ptr = iter->base.current_impl(it); return ptr == NULL ? NULL : *ptr; } static struct cx_iterator_s cx_pl_iterator( - struct cx_list_s const *list, + const struct cx_list_s *list, size_t index, bool backwards ) { @@ -215,7 +215,7 @@ } static void *cx_emptyl_at( - __attribute__((__unused__)) struct cx_list_s const *list, + __attribute__((__unused__)) const struct cx_list_s *list, __attribute__((__unused__)) size_t index ) { return NULL; @@ -223,18 +223,18 @@ static ssize_t cx_emptyl_find_remove( __attribute__((__unused__)) struct cx_list_s *list, - __attribute__((__unused__)) void const *elem, + __attribute__((__unused__)) const void *elem, __attribute__((__unused__)) bool remove ) { return -1; } -static bool cx_emptyl_iter_valid(__attribute__((__unused__)) void const *iter) { +static bool cx_emptyl_iter_valid(__attribute__((__unused__)) const void *iter) { return false; } static CxIterator cx_emptyl_iterator( - struct cx_list_s const *list, + const struct cx_list_s *list, size_t index, __attribute__((__unused__)) bool backwards ) { @@ -288,11 +288,11 @@ size_t cx_list_default_insert_array( struct cx_list_s *list, size_t index, - void const *data, + const void *data, size_t n ) { size_t elem_size = list->collection.elem_size; - char const *src = data; + const char *src = data; size_t i = 0; for (; i < n; i++) { if (0 != invoke_list_func(insert_element, @@ -305,7 +305,7 @@ size_t cx_list_default_insert_sorted( struct cx_list_s *list, - void const *sorted_data, + const void *sorted_data, size_t n ) { // corner case @@ -313,14 +313,14 @@ size_t elem_size = list->collection.elem_size; cx_compare_func cmp = list->collection.cmpfunc; - char const *src = sorted_data; + const char *src = sorted_data; // track indices and number of inserted items size_t di = 0, si = 0, inserted = 0; // search the list for insertion points for (; di < list->collection.size; di++) { - void const *list_elm = invoke_list_func(at, list, di); + const void *list_elm = invoke_list_func(at, list, di); // compare current list element with first source element // if less or equal, skip @@ -330,7 +330,7 @@ // determine number of consecutive elements that can be inserted size_t ins = 1; - char const *next = src; + const char *next = src; while (++si < n) { next += elem_size; // once we become larger than the list elem, break @@ -422,8 +422,8 @@ } int cxListCompare( - CxList const *list, - CxList const *other + const CxList *list, + const CxList *other ) { bool cannot_optimize = false;
--- a/src/map.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/map.c Sat Sep 28 15:47:28 2024 +0200 @@ -36,18 +36,18 @@ } static void *cx_empty_map_get( - __attribute__((__unused__)) CxMap const *map, + __attribute__((__unused__)) const CxMap *map, __attribute__((__unused__)) CxHashKey key ) { return NULL; } -static bool cx_empty_map_iter_valid(__attribute__((__unused__)) void const *iter) { +static bool cx_empty_map_iter_valid(__attribute__((__unused__)) const void *iter) { return false; } static CxIterator cx_empty_map_iterator( - struct cx_map_s const *map, + const struct cx_map_s *map, __attribute__((__unused__)) enum cx_map_iterator_type type ) { CxIterator iter = {0};
--- a/src/printf.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/printf.c Sat Sep 28 15:47:28 2024 +0200 @@ -39,7 +39,7 @@ int cx_fprintf( void *stream, cx_write_func wfc, - char const *fmt, + const char *fmt, ... ) { int ret; @@ -53,7 +53,7 @@ int cx_vfprintf( void *stream, cx_write_func wfc, - char const *fmt, + const char *fmt, va_list ap ) { char buf[CX_PRINTF_SBO_SIZE]; @@ -85,8 +85,8 @@ } cxmutstr cx_asprintf_a( - CxAllocator const *allocator, - char const *fmt, + const CxAllocator *allocator, + const char *fmt, ... ) { va_list ap; @@ -97,8 +97,8 @@ } cxmutstr cx_vasprintf_a( - CxAllocator const *a, - char const *fmt, + const CxAllocator *a, + const char *fmt, va_list ap ) { cxmutstr s;
--- a/src/string.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/string.c Sat Sep 28 15:47:28 2024 +0200 @@ -72,7 +72,7 @@ } void cx_strfree_a( - CxAllocator const *alloc, + const CxAllocator *alloc, cxmutstr *str ) { cxFree(alloc, str->ptr); @@ -99,7 +99,7 @@ } cxmutstr cx_strcat_ma( - CxAllocator const *alloc, + const CxAllocator *alloc, cxmutstr str, size_t count, ... @@ -377,7 +377,7 @@ } size_t cx_strsplit_a( - CxAllocator const *allocator, + const CxAllocator *allocator, cxstring string, cxstring delim, size_t limit, @@ -419,7 +419,7 @@ } size_t cx_strsplit_ma( - CxAllocator const *allocator, + const CxAllocator *allocator, cxmutstr string, cxstring delim, size_t limit, @@ -460,25 +460,25 @@ } int cx_strcmp_p( - void const *s1, - void const *s2 + const void *s1, + const void *s2 ) { - cxstring const *left = s1; - cxstring const *right = s2; + const cxstring *left = s1; + const cxstring *right = s2; return cx_strcmp(*left, *right); } int cx_strcasecmp_p( - void const *s1, - void const *s2 + const void *s1, + const void *s2 ) { - cxstring const *left = s1; - cxstring const *right = s2; + const cxstring *left = s1; + const cxstring *right = s2; return cx_strcasecmp(*left, *right); } cxmutstr cx_strdup_a( - CxAllocator const *allocator, + const CxAllocator *allocator, cxstring string ) { cxmutstr result = { @@ -587,7 +587,7 @@ } cxmutstr cx_strreplacen_a( - CxAllocator const *allocator, + const CxAllocator *allocator, cxstring str, cxstring pattern, cxstring replacement, @@ -778,7 +778,7 @@ void cx_strtok_delim( CxStrtokCtx *ctx, - cxstring const *delim, + const cxstring *delim, size_t count ) { ctx->delim_more = delim;
--- a/src/tree.c Wed Sep 18 00:02:18 2024 +0200 +++ b/src/tree.c Sat Sep 28 15:47:28 2024 +0200 @@ -134,8 +134,8 @@ } int cx_tree_search( - void const *root, - void const *node, + const void *root, + const void *node, cx_tree_search_func sfunc, void **result, ptrdiff_t loc_children, @@ -154,7 +154,7 @@ } // create a working stack - CX_ARRAY_DECLARE(void const*, work); + CX_ARRAY_DECLARE(const void *, work); cx_array_initialize(work, 32); // add the children of root to the working stack @@ -174,7 +174,7 @@ // process the working stack while (work_size > 0) { // pop element - void const *elem = work[--work_size]; + const void *elem = work[--work_size]; // apply the search function ret = sfunc(elem, node); @@ -212,8 +212,8 @@ } int cx_tree_search_data( - void const *root, - void const *data, + const void *root, + const void *data, cx_tree_search_data_func sfunc, void **result, ptrdiff_t loc_children, @@ -227,13 +227,13 @@ loc_children, loc_next); } -static bool cx_tree_iter_valid(void const *it) { - struct cx_tree_iterator_s const *iter = it; +static bool cx_tree_iter_valid(const void *it) { + const struct cx_tree_iterator_s *iter = it; return iter->node != NULL; } -static void *cx_tree_iter_current(void const *it) { - struct cx_tree_iterator_s const *iter = it; +static void *cx_tree_iter_current(const void *it) { + const struct cx_tree_iterator_s *iter = it; return iter->node; } @@ -351,13 +351,13 @@ return iter; } -static bool cx_tree_visitor_valid(void const *it) { - struct cx_tree_visitor_s const *iter = it; +static bool cx_tree_visitor_valid(const void *it) { + const struct cx_tree_visitor_s *iter = it; return iter->node != NULL; } -static void *cx_tree_visitor_current(void const *it) { - struct cx_tree_visitor_s const *iter = it; +static void *cx_tree_visitor_current(const void *it) { + const struct cx_tree_visitor_s *iter = it; return iter->node; } @@ -497,7 +497,7 @@ } int cx_tree_add( - void const *src, + const void *src, cx_tree_search_func sfunc, cx_tree_node_create_func cfunc, void *cdata, @@ -560,7 +560,7 @@ size_t processed = 0; void *current_node = root; - void const *elem; + const void *elem; for (void **eptr; iter->valid(iter) && (eptr = iter->current(iter)) != NULL; @@ -621,7 +621,7 @@ } size_t cx_tree_add_array( - void const *src, + const void *src, size_t num, size_t elem_size, cx_tree_search_func sfunc,
--- a/tests/test_buffer.c Wed Sep 18 00:02:18 2024 +0200 +++ b/tests/test_buffer.c Sat Sep 28 15:47:28 2024 +0200 @@ -586,7 +586,7 @@ } static size_t mock_write_limited_rate( - void const *ptr, + const void *ptr, size_t size, __attribute__((unused)) size_t nitems, CxBuffer *buffer
--- a/tests/test_hash_key.c Wed Sep 18 00:02:18 2024 +0200 +++ b/tests/test_hash_key.c Sat Sep 28 15:47:28 2024 +0200 @@ -32,11 +32,11 @@ #include "cx/string.h" CX_TEST(test_hash_key_functions) { - char const* str = "my key"; + const char *str = "my key"; size_t len = strlen(str); CxHashKey str_key = cx_hash_key_str(str); - CxHashKey bytes_key = cx_hash_key_bytes((unsigned char const*)str, len); + CxHashKey bytes_key = cx_hash_key_bytes((const unsigned char*)str, len); CxHashKey obj_key = cx_hash_key(str, len); CxHashKey cxstr_key = cx_hash_key_cxstr(cx_str(str)); @@ -53,10 +53,10 @@ } CX_TEST(test_hash_key_empty_string) { - char const* str = ""; + const char *str = ""; CxHashKey str_key = cx_hash_key_str(str); - CxHashKey bytes_key = cx_hash_key_bytes((unsigned char const*) str, 0); + CxHashKey bytes_key = cx_hash_key_bytes((const unsigned char*) str, 0); CxHashKey obj_key = cx_hash_key(str, 0); CX_TEST_DO {
--- a/tests/test_hash_map.c Wed Sep 18 00:02:18 2024 +0200 +++ b/tests/test_hash_map.c Sat Sep 28 15:47:28 2024 +0200 @@ -242,7 +242,7 @@ CxIterator iter = cxMapMutIterator(map); cx_foreach(CxMapEntry*, entry, iter) { - if (((char const *)entry->key->data)[4] % 2 == 1) cxIteratorFlagRemoval(iter); + if (((const char *)entry->key->data)[4] % 2 == 1) cxIteratorFlagRemoval(iter); } CX_TEST_ASSERT(map->collection.size == 3); CX_TEST_ASSERT(iter.index == map->collection.size); @@ -438,7 +438,7 @@ // note: we don't have a destructor here, so remove and detach are the same cxMapRemove(map, cx_str("test")); - char const *hallo = "hallo"; + const char *hallo = "hallo"; cxMapDetach(map, hallo); cxMapPut(map, cx_hash_key_str("key"), "value"); @@ -460,8 +460,8 @@ } struct test_map_kv { - char const *key; - char const *value; + const char *key; + const char *value; }; static struct test_map_kv const test_map_operations[] = { @@ -499,7 +499,7 @@ static size_t const test_map_reference_len = sizeof(test_map_reference) / sizeof(struct test_map_kv); -static void test_map_reference_put(char const *key, char const* value) { +static void test_map_reference_put(const char *key, const char *value) { for (size_t i = 0 ; i < test_map_reference_len ; i++) { if (0 == strcmp(key, test_map_reference[i].key)) { test_map_reference[i].value = value; @@ -508,7 +508,7 @@ } } -static char const *test_map_reference_get(char const *key) { +static const char *test_map_reference_get(const char *key) { for (size_t i = 0 ; i < test_map_reference_len ; i++) { if (0 == strcmp(key, test_map_reference[i].key)) { return test_map_reference[i].value; @@ -517,10 +517,10 @@ return NULL; } -static char const *test_map_reference_remove(char const *key) { +static const char *test_map_reference_remove(const char *key) { for (size_t i = 0 ; i < test_map_reference_len ; i++) { if (0 == strcmp(key, test_map_reference[i].key)) { - char const *ret = test_map_reference[i].value; + const char *ret = test_map_reference[i].value; test_map_reference[i].value = NULL; return ret; } @@ -569,8 +569,8 @@ CxIterator valiter = cxMapIteratorValues(map); CX_TEST_ASSERT(valiter.elem_size == map->collection.elem_size); CX_TEST_ASSERT(valiter.elem_count == map->collection.size); - char const** values = calloc(map->collection.size, sizeof(char const*)); - cx_foreach(char const*, elem, valiter) { + const char ** values = calloc(map->collection.size, sizeof(const char *)); + cx_foreach(const char *, elem, valiter) { values[valiter.index] = elem; } CX_TEST_ASSERT(valiter.index == map->collection.size); @@ -595,7 +595,7 @@ CX_TEST_ASSERT(pairiter.elem_count == map->collection.size); struct test_map_kv *pairs = calloc(map->collection.size, sizeof(struct test_map_kv)); cx_foreach(CxMapEntry*, entry, pairiter) { - CxHashKey const *key = entry->key; + const CxHashKey *key = entry->key; pairs[pairiter.index].key = cx_strdup(cx_strn(key->data, key->len)).ptr; pairs[pairiter.index].value = entry->value; } @@ -640,7 +640,7 @@ CX_TEST_ASSERT(0 == memcmp(kv.value, added, strlen(kv.value))); } else { // execute a remove and verify that the removed element was returned (or NULL) - char const *found = test_map_reference_remove(kv.key); + const char *found = test_map_reference_remove(kv.key); void *removed = cxMapRemoveAndGet(map, key); CX_TEST_ASSERT(found == removed); }
--- a/tests/test_list.c Wed Sep 18 00:02:18 2024 +0200 +++ b/tests/test_list.c Sat Sep 28 15:47:28 2024 +0200 @@ -1050,7 +1050,7 @@ roll_out_test_invokers(name) static void set_default_class_funcs(CxList *list, cx_list_class *defaulted_cl) { - cx_list_class const *cl = list->climpl == NULL ? list->cl : list->climpl; + const cx_list_class *cl = list->climpl == NULL ? list->cl : list->climpl; memcpy(defaulted_cl, cl, sizeof(cx_list_class)); defaulted_cl->insert_array = cx_list_default_insert_array; defaulted_cl->insert_sorted = cx_list_default_insert_sorted; @@ -1564,7 +1564,7 @@ } static CX_TEST_SUBROUTINE(test_list_verify_destructor, CxList *list, - int const *testdata, size_t testdata_len) { + const int *testdata, size_t testdata_len) { destr_test_ctr = 0; int off = cxListIsStoringPointers(list) ? 1 : 0;
--- a/tests/test_printf.c Wed Sep 18 00:02:18 2024 +0200 +++ b/tests/test_printf.c Sat Sep 28 15:47:28 2024 +0200 @@ -36,7 +36,7 @@ #str " is not zero terminated") static size_t test_printf_write_func( - void const *src, + const void *src, size_t esize, size_t ecount, void *target @@ -114,7 +114,7 @@ } CX_TEST(test_fprintf) { - char const *h = "Hello"; + const char *h = "Hello"; char buf[32]; size_t r; CX_TEST_DO { @@ -177,7 +177,7 @@ cx_testing_allocator_init(&talloc); CxAllocator *alloc = &talloc.base; - char const *h = "Hello"; + const char *h = "Hello"; int const specimen_count = 13; cxmutstr r[specimen_count];
--- a/tests/test_string.c Wed Sep 18 00:02:18 2024 +0200 +++ b/tests/test_string.c Sat Sep 28 15:47:28 2024 +0200 @@ -622,45 +622,45 @@ cxstring csstr = CX_STR("test AB ab TEST xyz"); cxmutstr repl = cx_strreplace(str, CX_STR("abab"), CX_STR("muchlonger")); - char const *expected = "test muchlongerab string aba"; + const char *expected = "test muchlongerab string aba"; cxmutstr repln = cx_strreplacen(str, CX_STR("ab"), CX_STR("c"), 2); - char const *expectedn = "test ccab string aba"; + const char *expectedn = "test ccab string aba"; cxmutstr longrepl = cx_strreplace(longstr, CX_STR("a"), CX_STR("z")); - char const *longexpect = "xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzcd"; + const char *longexpect = "xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzcd"; cxmutstr replnotrail = cx_strreplace(notrail, CX_STR("ab"), CX_STR("z")); - char const *notrailexpect = "test zz"; + const char *notrailexpect = "test zz"; cxmutstr repleq = cx_strreplace(str, str, CX_STR("hello")); - char const *eqexpect = "hello"; + const char *eqexpect = "hello"; cxmutstr replempty1 = cx_strreplace(empty, CX_STR("ab"), CX_STR("c")); // expect: empty cxmutstr replempty2 = cx_strreplace(str, CX_STR("abab"), empty); - char const *emptyexpect2 = "test ab string aba"; + const char *emptyexpect2 = "test ab string aba"; cxmutstr replpre = cx_strreplace(str, CX_STR("test "), CX_STR("TEST ")); - char const *preexpected = "TEST ababab string aba"; + const char *preexpected = "TEST ababab string aba"; cxmutstr replan1 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 1); - char const *an1expected = "xaaaaaaaaa"; + const char *an1expected = "xaaaaaaaaa"; cxmutstr replan4 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 4); - char const *an4expected = "xxxxaaaaaa"; + const char *an4expected = "xxxxaaaaaa"; cxmutstr replan9 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 9); - char const *an9expected = "xxxxxxxxxa"; + const char *an9expected = "xxxxxxxxxa"; cxmutstr replan10 = cx_strreplacen(astr, CX_STR("a"), CX_STR("x"), 10); - char const *an10expected = "xxxxxxxxxx"; + const char *an10expected = "xxxxxxxxxx"; CX_TEST_DO { cxmutstr repl1_a = cx_strreplace_a(alloc, csstr, CX_STR("AB"), CX_STR("*")); - char const *expeced1_a = "test * ab TEST xyz"; + const char *expeced1_a = "test * ab TEST xyz"; cxmutstr repl2_a = cx_strreplace_a(alloc, csstr, CX_STR("test"), CX_STR("TEST")); - char const *expected2_a = "TEST AB ab TEST xyz"; + const char *expected2_a = "TEST AB ab TEST xyz"; CX_TEST_ASSERT(repl.ptr != str.ptr); ASSERT_ZERO_TERMINATED(repl);
--- a/tests/test_tree.c Wed Sep 18 00:02:18 2024 +0200 +++ b/tests/test_tree.c Sat Sep 28 15:47:28 2024 +0200 @@ -55,11 +55,11 @@ struct tree_node_file *prev; struct tree_node_file *children; struct tree_node_file *last_child; - char const *path; + const char *path; } tree_node_file; static void *create_tree_node_file( - void const *dptr, + const void *dptr, void *allocator) { if (allocator == NULL) allocator = cxDefaultAllocator; @@ -76,9 +76,9 @@ return node; } -static int tree_node_file_search(void const *l, void const *r) { - tree_node_file const *left = l; - tree_node_file const *right = r; +static int tree_node_file_search(const void *l, const void *r) { + const tree_node_file *left = l; + const tree_node_file *right = r; size_t len1 = strlen(left->path); size_t len2 = strlen(right->path); if (len1 <= len2) { @@ -371,9 +371,9 @@ } } -static int test_tree_search_function(void const *n, void const *d) { - tree_node const *node = n; - int data = *((int const*)d); +static int test_tree_search_function(const void *n, const void *d) { + const tree_node *node = n; + int data = *((const int *)d); if (data < node->data) return -1; else if (data == node->data) return 0; @@ -601,7 +601,7 @@ typedef struct test_xml_node { struct tree_node base; - char const* name; + const char *name; } test_xml_node; CX_TEST(test_tree_iterator_xml) { @@ -649,7 +649,7 @@ cx_tree_link(&target, &target_dependencies, tree_node_layout); cx_tree_link(&target_feature, &target_feature_dependencies, tree_node_layout); - char const *expected = + const char *expected = "<project><config><var></var><var></var><var></var></config>" "<dependency><make></make></dependency><dependency><lang></lang><make></make></dependency>" "<target><feature><dependencies></dependencies></feature><dependencies></dependencies></target></project>"; @@ -1067,10 +1067,10 @@ ); CX_TEST_ASSERT(result == 0); CX_TEST_ASSERT(foo != NULL); - char const *bar_path = "/home/foo/bar/"; + const char *bar_path = "/home/foo/bar/"; void *failed; size_t added = cx_tree_add_array( - bar_path, 1, sizeof(char const *), + bar_path, 1, sizeof(const char *), tree_node_file_search, create_tree_node_file, alloc, &failed, &root, @@ -1166,7 +1166,7 @@ free(node); node = NULL; size_t added = cx_tree_add_array( - "/", 1, sizeof(char const *), + "/", 1, sizeof(const char *), tree_node_file_search, create_tree_node_file, NULL, (void **) &node, &root, @@ -1256,7 +1256,7 @@ CX_TEST_DO { void *failed; - char const *paths[] = { + const char *paths[] = { "/home/foo/", "/home/foo/bar", "/usr/lib64/", @@ -1264,7 +1264,7 @@ }; size_t processed = cx_tree_add_array( - paths, 4, sizeof(char const *), + paths, 4, sizeof(const char *), tree_node_file_search, create_tree_node_file, alloc, &failed, &root, tree_node_file_layout @@ -1311,7 +1311,7 @@ CX_TEST_DO { tree_node_file *failed; - char const *paths[] = { + const char *paths[] = { "/mnt/sdcard/", "/mnt/foo/", "/mnt/sdcard/", @@ -1320,7 +1320,7 @@ }; size_t processed = cx_tree_add_array( - paths, 5, sizeof(char const *), + paths, 5, sizeof(const char *), tree_node_file_search, create_tree_node_file, alloc, (void **) &failed, &root, tree_node_file_layout @@ -1358,13 +1358,13 @@ } static CX_TEST_SUBROUTINE(test_tree_add_create_from_array_impl, - CxAllocator *alloc, char const **paths) { + CxAllocator *alloc, const char **paths) { tree_node_file root = {0}; root.path = "/"; void *failed; size_t processed = cx_tree_add_array( - paths, 10, sizeof(char const *), + paths, 10, sizeof(const char *), tree_node_file_search, create_tree_node_file, alloc, &failed, &root, tree_node_file_layout @@ -1373,7 +1373,7 @@ CX_TEST_ASSERT(failed == NULL); CX_TEST_ASSERT(processed == 10); - char const *exp_order[] = { + const char *exp_order[] = { "/", "/usr/", "/usr/lib/", @@ -1426,7 +1426,7 @@ CxAllocator *alloc = &talloc.base; CX_TEST_DO { - char const *paths[] = { + const char *paths[] = { "/usr/", "/home/", "/usr/lib/", @@ -1439,7 +1439,7 @@ "/home/foo/" }; - char const *scrambled_paths[] = { + const char *scrambled_paths[] = { "/usr/", "/home/", "/var/www/vhosts/live/",
--- a/tests/util_allocator.c Wed Sep 18 00:02:18 2024 +0200 +++ b/tests/util_allocator.c Sat Sep 28 15:47:28 2024 +0200 @@ -147,11 +147,11 @@ free(alloc->tracked); } -bool cx_testing_allocator_used(CxTestingAllocator const *alloc) { +bool cx_testing_allocator_used(const CxTestingAllocator *alloc) { return alloc->alloc_total > 0; } -bool cx_testing_allocator_verify(CxTestingAllocator const *alloc) { +bool cx_testing_allocator_verify(const CxTestingAllocator *alloc) { return alloc->tracked_count == 0 && alloc->alloc_failed == 0 && alloc->free_failed == 0 && alloc->alloc_total == alloc->free_total; }
--- a/tests/util_allocator.h Wed Sep 18 00:02:18 2024 +0200 +++ b/tests/util_allocator.h Sat Sep 28 15:47:28 2024 +0200 @@ -86,14 +86,14 @@ * * @return true if any allocation was attempted using this allocator */ -bool cx_testing_allocator_used(CxTestingAllocator const *alloc); +bool cx_testing_allocator_used(const CxTestingAllocator *alloc); /** * Verifies that all allocated memory blocks are freed and no free occurred twice. * * @return true iff all tracked allocations / deallocations were valid */ -bool cx_testing_allocator_verify(CxTestingAllocator const *alloc); +bool cx_testing_allocator_verify(const CxTestingAllocator *alloc); #ifdef __cplusplus } // extern "C"