ucx/string.c

changeset 1016
ccde46662db7
parent 943
9b5948aa5b90
--- a/ucx/string.c	Wed Dec 17 18:31:20 2025 +0100
+++ b/ucx/string.c	Thu Dec 18 17:50:15 2025 +0100
@@ -25,9 +25,9 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#ifdef MEMRCHR_NEED_GNU
+
+// for memrchr in glibc
 #define _GNU_SOURCE
-#endif
 
 #include "cx/string.h"
 
@@ -46,28 +46,6 @@
 #define cx_strcasecmp_impl strncasecmp
 #endif
 
-cxmutstr cx_mutstr(char *cstring) {
-    return (cxmutstr) {cstring, cstring == NULL ? 0 : strlen(cstring)};
-}
-
-cxmutstr cx_mutstrn(
-        char *cstring,
-        size_t length
-) {
-    return (cxmutstr) {cstring, length};
-}
-
-cxstring cx_str(const char *cstring) {
-    return (cxstring) {cstring, cstring == NULL ? 0 : strlen(cstring)};
-}
-
-cxstring cx_strn(
-        const char *cstring,
-        size_t length
-) {
-    return (cxstring) {cstring, length};
-}
-
 void cx_strfree(cxmutstr *str) {
     if (str == NULL) return;
     cxFreeDefault(str->ptr);
@@ -264,10 +242,10 @@
     return (cxmutstr) {(char *) result.ptr, result.length};
 }
 
-#ifndef CX_STRSTR_SBO_SIZE
-#define CX_STRSTR_SBO_SIZE 128
+#ifndef cx_strSTR_SBO_SIZE
+#define cx_strSTR_SBO_SIZE 128
 #endif
-const unsigned cx_strstr_sbo_size = CX_STRSTR_SBO_SIZE;
+const unsigned cx_strstr_sbo_size = cx_strSTR_SBO_SIZE;
 
 cxstring cx_strstr(
         cxstring haystack,
@@ -291,11 +269,11 @@
      */
 
     // local prefix table
-    size_t s_prefix_table[CX_STRSTR_SBO_SIZE];
+    size_t s_prefix_table[cx_strSTR_SBO_SIZE];
 
     // check needle length and use appropriate prefix table
     // if the pattern exceeds static prefix table, allocate on the heap
-    const bool useheap = needle.length >= CX_STRSTR_SBO_SIZE;
+    const bool useheap = needle.length >= cx_strSTR_SBO_SIZE;
     register size_t *ptable = useheap
         ? cxCallocDefault(needle.length + 1, sizeof(size_t))
         : s_prefix_table;

mercurial