fix several survivors of east-const and some missing consts

Sun, 13 Oct 2024 14:06:32 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 13 Oct 2024 14:06:32 +0200
changeset 926
8fdd8d78c14b
parent 925
fd6e191f3268
child 927
71e7e9ba4b97

fix several survivors of east-const and some missing consts

src/array_list.c file | annotate | diff | comparison | revisions
src/cx/array_list.h file | annotate | diff | comparison | revisions
src/cx/linked_list.h file | annotate | diff | comparison | revisions
src/cx/printf.h file | annotate | diff | comparison | revisions
src/cx/string.h file | annotate | diff | comparison | revisions
src/linked_list.c file | annotate | diff | comparison | revisions
src/printf.c file | annotate | diff | comparison | revisions
src/string.c file | annotate | diff | comparison | revisions
tests/test_hash_map.c file | annotate | diff | comparison | revisions
tests/test_string.c file | annotate | diff | comparison | revisions
--- 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,
--- 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.
--- 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.
--- 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
--- 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.
--- 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,
--- 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,
--- 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,
--- 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) {
--- 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

mercurial