63 cxstring cx_strcast(cxmutstr str) { |
63 cxstring cx_strcast(cxmutstr str) { |
64 return (cxstring) {str.ptr, str.length}; |
64 return (cxstring) {str.ptr, str.length}; |
65 } |
65 } |
66 |
66 |
67 void cx_strfree(cxmutstr *str) { |
67 void cx_strfree(cxmutstr *str) { |
|
68 if (str == NULL) return; |
68 free(str->ptr); |
69 free(str->ptr); |
69 str->ptr = NULL; |
70 str->ptr = NULL; |
70 str->length = 0; |
71 str->length = 0; |
71 } |
72 } |
72 |
73 |
73 void cx_strfree_a( |
74 void cx_strfree_a( |
74 const CxAllocator *alloc, |
75 const CxAllocator *alloc, |
75 cxmutstr *str |
76 cxmutstr *str |
76 ) { |
77 ) { |
|
78 if (str == NULL) return; |
77 cxFree(alloc, str->ptr); |
79 cxFree(alloc, str->ptr); |
78 str->ptr = NULL; |
80 str->ptr = NULL; |
79 str->length = 0; |
81 str->length = 0; |
80 } |
82 } |
81 |
83 |