| 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
27 */ |
| 28 #ifdef MEMRCHR_NEED_GNU |
28 |
| |
29 #ifdef WITH_MEMRCHR |
| 29 #define _GNU_SOURCE |
30 #define _GNU_SOURCE |
| 30 #endif |
31 #endif |
| 31 |
32 |
| 32 #include "cx/string.h" |
33 #include "cx/string.h" |
| 33 |
34 |
| 43 #define cx_strcasecmp_impl _strnicmp |
44 #define cx_strcasecmp_impl _strnicmp |
| 44 #else |
45 #else |
| 45 #include <strings.h> |
46 #include <strings.h> |
| 46 #define cx_strcasecmp_impl strncasecmp |
47 #define cx_strcasecmp_impl strncasecmp |
| 47 #endif |
48 #endif |
| 48 |
|
| 49 cxmutstr cx_mutstr(char *cstring) { |
|
| 50 return (cxmutstr) {cstring, cstring == NULL ? 0 : strlen(cstring)}; |
|
| 51 } |
|
| 52 |
|
| 53 cxmutstr cx_mutstrn( |
|
| 54 char *cstring, |
|
| 55 size_t length |
|
| 56 ) { |
|
| 57 return (cxmutstr) {cstring, length}; |
|
| 58 } |
|
| 59 |
|
| 60 cxstring cx_str(const char *cstring) { |
|
| 61 return (cxstring) {cstring, cstring == NULL ? 0 : strlen(cstring)}; |
|
| 62 } |
|
| 63 |
|
| 64 cxstring cx_strn( |
|
| 65 const char *cstring, |
|
| 66 size_t length |
|
| 67 ) { |
|
| 68 return (cxstring) {cstring, length}; |
|
| 69 } |
|
| 70 |
49 |
| 71 void cx_strfree(cxmutstr *str) { |
50 void cx_strfree(cxmutstr *str) { |
| 72 if (str == NULL) return; |
51 if (str == NULL) return; |
| 73 cxFreeDefault(str->ptr); |
52 cxFreeDefault(str->ptr); |
| 74 str->ptr = NULL; |
53 str->ptr = NULL; |