src/string.c

changeset 1334
7763892ed801
parent 1319
aa1f580f8f59
equal deleted inserted replaced
1333:2fc1c25441f1 1334:7763892ed801
40 #include <strings.h> 40 #include <strings.h>
41 #define cx_strcasecmp_impl strncasecmp 41 #define cx_strcasecmp_impl strncasecmp
42 #endif 42 #endif
43 43
44 cxmutstr cx_mutstr(char *cstring) { 44 cxmutstr cx_mutstr(char *cstring) {
45 return (cxmutstr) {cstring, strlen(cstring)}; 45 return (cxmutstr) {cstring, cstring == NULL ? 0 : strlen(cstring)};
46 } 46 }
47 47
48 cxmutstr cx_mutstrn( 48 cxmutstr cx_mutstrn(
49 char *cstring, 49 char *cstring,
50 size_t length 50 size_t length
51 ) { 51 ) {
52 return (cxmutstr) {cstring, length}; 52 return (cxmutstr) {cstring, length};
53 } 53 }
54 54
55 cxstring cx_str(const char *cstring) { 55 cxstring cx_str(const char *cstring) {
56 return (cxstring) {cstring, strlen(cstring)}; 56 return (cxstring) {cstring, cstring == NULL ? 0 : strlen(cstring)};
57 } 57 }
58 58
59 cxstring cx_strn( 59 cxstring cx_strn(
60 const char *cstring, 60 const char *cstring,
61 size_t length 61 size_t length

mercurial