# HG changeset patch # User Mike Becker # Date 1728821192 -7200 # Node ID 8fdd8d78c14b2f863993e308a5a18aaa493a02b7 # Parent fd6e191f32683369fcd5b5f41e50f625f613018c fix several survivors of east-const and some missing consts diff -r fd6e191f3268 -r 8fdd8d78c14b src/array_list.c --- a/src/array_list.c Sat Oct 12 19:41:04 2024 +0200 +++ b/src/array_list.c Sun Oct 13 14:06:32 2024 +0200 @@ -290,7 +290,7 @@ #ifndef CX_ARRAY_SWAP_SBO_SIZE #define CX_ARRAY_SWAP_SBO_SIZE 128 #endif -unsigned cx_array_swap_sbo_size = CX_ARRAY_SWAP_SBO_SIZE; +const unsigned cx_array_swap_sbo_size = CX_ARRAY_SWAP_SBO_SIZE; void cx_array_swap( void *arr, diff -r fd6e191f3268 -r 8fdd8d78c14b src/cx/array_list.h --- a/src/cx/array_list.h Sat Oct 12 19:41:04 2024 +0200 +++ b/src/cx/array_list.h Sun Oct 13 14:06:32 2024 +0200 @@ -47,7 +47,7 @@ /** * The maximum item size in an array list that fits into stack buffer when swapped. */ -extern unsigned cx_array_swap_sbo_size; +extern const unsigned cx_array_swap_sbo_size; /** * Declares variables for an array that can be used with the convenience macros. diff -r fd6e191f3268 -r 8fdd8d78c14b src/cx/linked_list.h --- a/src/cx/linked_list.h Sat Oct 12 19:41:04 2024 +0200 +++ b/src/cx/linked_list.h Sun Oct 13 14:06:32 2024 +0200 @@ -47,7 +47,7 @@ /** * The maximum item size that uses SBO swap instead of relinking. */ -extern unsigned cx_linked_list_swap_sbo_size; +extern const unsigned cx_linked_list_swap_sbo_size; /** * Allocates a linked list for storing elements with \p elem_size bytes each. diff -r fd6e191f3268 -r 8fdd8d78c14b src/cx/printf.h --- a/src/cx/printf.h Sat Oct 12 19:41:04 2024 +0200 +++ b/src/cx/printf.h Sun Oct 13 14:06:32 2024 +0200 @@ -48,7 +48,7 @@ /** * The maximum string length that fits into stack memory. */ -extern unsigned const cx_printf_sbo_size; +extern const unsigned cx_printf_sbo_size; /** * A \c fprintf like function which writes the output to a stream by diff -r fd6e191f3268 -r 8fdd8d78c14b src/cx/string.h --- a/src/cx/string.h Sat Oct 12 19:41:04 2024 +0200 +++ b/src/cx/string.h Sun Oct 13 14:06:32 2024 +0200 @@ -42,7 +42,7 @@ /** * The maximum length of the "needle" in cx_strstr() that can use SBO. */ -extern unsigned const cx_strstr_sbo_size; +extern const unsigned cx_strstr_sbo_size; /** * The UCX string structure. diff -r fd6e191f3268 -r 8fdd8d78c14b src/linked_list.c --- a/src/linked_list.c Sat Oct 12 19:41:04 2024 +0200 +++ b/src/linked_list.c Sun Oct 13 14:06:32 2024 +0200 @@ -819,7 +819,7 @@ #ifndef CX_LINKED_LIST_SWAP_SBO_SIZE #define CX_LINKED_LIST_SWAP_SBO_SIZE 128 #endif -unsigned cx_linked_list_swap_sbo_size = CX_LINKED_LIST_SWAP_SBO_SIZE; +const unsigned cx_linked_list_swap_sbo_size = CX_LINKED_LIST_SWAP_SBO_SIZE; static int cx_ll_swap( struct cx_list_s *list, diff -r fd6e191f3268 -r 8fdd8d78c14b src/printf.c --- a/src/printf.c Sat Oct 12 19:41:04 2024 +0200 +++ b/src/printf.c Sun Oct 13 14:06:32 2024 +0200 @@ -34,7 +34,7 @@ #ifndef CX_PRINTF_SBO_SIZE #define CX_PRINTF_SBO_SIZE 512 #endif -unsigned const cx_printf_sbo_size = CX_PRINTF_SBO_SIZE; +const unsigned cx_printf_sbo_size = CX_PRINTF_SBO_SIZE; int cx_fprintf( void *stream, diff -r fd6e191f3268 -r 8fdd8d78c14b src/string.c --- a/src/string.c Sat Oct 12 19:41:04 2024 +0200 +++ b/src/string.c Sun Oct 13 14:06:32 2024 +0200 @@ -236,7 +236,7 @@ #ifndef CX_STRSTR_SBO_SIZE #define CX_STRSTR_SBO_SIZE 512 #endif -unsigned const cx_strstr_sbo_size = CX_STRSTR_SBO_SIZE; +const unsigned cx_strstr_sbo_size = CX_STRSTR_SBO_SIZE; cxstring cx_strstr( cxstring haystack, diff -r fd6e191f3268 -r 8fdd8d78c14b tests/test_hash_map.c --- a/tests/test_hash_map.c Sat Oct 12 19:41:04 2024 +0200 +++ b/tests/test_hash_map.c Sun Oct 13 14:06:32 2024 +0200 @@ -483,7 +483,7 @@ {"key 2", NULL}, {"key 8", "new value"}, }; -static size_t const test_map_operations_len = +static const size_t test_map_operations_len = sizeof(test_map_operations) / sizeof(struct test_map_kv); static struct test_map_kv test_map_reference[] = { {"key 1", NULL}, @@ -496,7 +496,7 @@ {"key 8", NULL}, {"key 9", NULL}, }; -static size_t const test_map_reference_len = +static const size_t test_map_reference_len = sizeof(test_map_reference) / sizeof(struct test_map_kv); static void test_map_reference_put(const char *key, const char *value) { diff -r fd6e191f3268 -r 8fdd8d78c14b tests/test_string.c --- a/tests/test_string.c Sat Oct 12 19:41:04 2024 +0200 +++ b/tests/test_string.c Sun Oct 13 14:06:32 2024 +0200 @@ -176,8 +176,8 @@ CX_TEST(test_strstr) { cxstring str = CX_STR("find the match in this string"); - size_t const longstrpatternlen = 64 + cx_strstr_sbo_size; - size_t const longstrlen = 320 + longstrpatternlen + 14; + const size_t longstrpatternlen = 64 + cx_strstr_sbo_size; + const size_t longstrlen = 320 + longstrpatternlen + 14; // it is more expensive to use calloc here, because we will overwrite // the memory anyway in the test preparation - but it is more reliable