src/string.c

changeset 693
494d9b20b99e
parent 657
3eeadf666d6b
child 697
ebdce4bf262b
equal deleted inserted replaced
692:6ac92936cd44 693:494d9b20b99e
70 str->ptr = NULL; 70 str->ptr = NULL;
71 str->length = 0; 71 str->length = 0;
72 } 72 }
73 73
74 void cx_strfree_a( 74 void cx_strfree_a(
75 CxAllocator *alloc, 75 CxAllocator const *alloc,
76 cxmutstr *str 76 cxmutstr *str
77 ) { 77 ) {
78 cxFree(alloc, str->ptr); 78 cxFree(alloc, str->ptr);
79 str->ptr = NULL; 79 str->ptr = NULL;
80 str->length = 0; 80 str->length = 0;
97 97
98 return size; 98 return size;
99 } 99 }
100 100
101 cxmutstr cx_strcat_a( 101 cxmutstr cx_strcat_a(
102 CxAllocator *alloc, 102 CxAllocator const *alloc,
103 size_t count, 103 size_t count,
104 ... 104 ...
105 ) { 105 ) {
106 cxstring *strings = calloc(count, sizeof(cxstring)); 106 cxstring *strings = calloc(count, sizeof(cxstring));
107 if (!strings) abort(); 107 if (!strings) abort();
367 367
368 return n; 368 return n;
369 } 369 }
370 370
371 size_t cx_strsplit_a( 371 size_t cx_strsplit_a(
372 CxAllocator *allocator, 372 CxAllocator const *allocator,
373 cxstring string, 373 cxstring string,
374 cxstring delim, 374 cxstring delim,
375 size_t limit, 375 size_t limit,
376 cxstring **output 376 cxstring **output
377 ) { 377 ) {
409 return cx_strsplit(cx_strcast(string), 409 return cx_strsplit(cx_strcast(string),
410 delim, limit, (cxstring *) output); 410 delim, limit, (cxstring *) output);
411 } 411 }
412 412
413 size_t cx_strsplit_ma( 413 size_t cx_strsplit_ma(
414 CxAllocator *allocator, 414 CxAllocator const *allocator,
415 cxmutstr string, 415 cxmutstr string,
416 cxstring delim, 416 cxstring delim,
417 size_t limit, 417 size_t limit,
418 cxmutstr **output 418 cxmutstr **output
419 ) { 419 ) {
468 cxstring const *right = s2; 468 cxstring const *right = s2;
469 return cx_strcasecmp(*left, *right); 469 return cx_strcasecmp(*left, *right);
470 } 470 }
471 471
472 cxmutstr cx_strdup_a( 472 cxmutstr cx_strdup_a(
473 CxAllocator *allocator, 473 CxAllocator const *allocator,
474 cxstring string 474 cxstring string
475 ) { 475 ) {
476 cxmutstr result = { 476 cxmutstr result = {
477 cxMalloc(allocator, string.length + 1), 477 cxMalloc(allocator, string.length + 1),
478 string.length 478 string.length
577 buf = next; 577 buf = next;
578 } 578 }
579 } 579 }
580 580
581 cxmutstr cx_strreplacen_a( 581 cxmutstr cx_strreplacen_a(
582 CxAllocator *allocator, 582 CxAllocator const *allocator,
583 cxstring str, 583 cxstring str,
584 cxstring pattern, 584 cxstring pattern,
585 cxstring replacement, 585 cxstring replacement,
586 size_t replmax 586 size_t replmax
587 ) { 587 ) {

mercurial