src/ucx/string.c

changeset 613
b649d66c433e
parent 582
82b60a8dd55c
child 621
956c03c25edd
equal deleted inserted replaced
612:d647ba7f0db6 613:b649d66c433e
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