add CX_LINKED_LIST_SORT_SBO_SIZE macro

Thu, 23 Feb 2023 22:27:41 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 23 Feb 2023 22:27:41 +0100
changeset 661
0a71ac9547fd
parent 660
4738a9065907
child 662
d0d95740071b

add CX_LINKED_LIST_SORT_SBO_SIZE macro

src/linked_list.c file | annotate | diff | comparison | revisions
--- a/src/linked_list.c	Thu Feb 23 22:24:26 2023 +0100
+++ b/src/linked_list.c	Thu Feb 23 22:27:41 2023 +0100
@@ -279,6 +279,10 @@
     return size;
 }
 
+#ifndef CX_LINKED_LIST_SORT_SBO_SIZE
+#define CX_LINKED_LIST_SORT_SBO_SIZE 1024
+#endif
+
 static void *cx_linked_list_sort_merge(
         ptrdiff_t loc_prev,
         ptrdiff_t loc_next,
@@ -289,9 +293,9 @@
         void *re,
         CxListComparator cmp_func
 ) {
-    const size_t sbo_len = 1024;
-    void *sbo[sbo_len];
-    void **sorted = (length >= sbo_len) ? malloc(sizeof(void *) * length) : sbo;
+    void *sbo[CX_LINKED_LIST_SORT_SBO_SIZE];
+    void **sorted = length >= CX_LINKED_LIST_SORT_SBO_SIZE ?
+            malloc(sizeof(void *) * length) : sbo;
     if (sorted == NULL) abort();
     void *rc, *lc;
 

mercurial