src/string.c

changeset 890
54565fd74e74
parent 806
e06249e09f99
equal deleted inserted replaced
889:f549fd9fbd8f 890:54565fd74e74
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 const *alloc, 75 const CxAllocator *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_ma( 101 cxmutstr cx_strcat_ma(
102 CxAllocator const *alloc, 102 const CxAllocator *alloc,
103 cxmutstr str, 103 cxmutstr str,
104 size_t count, 104 size_t count,
105 ... 105 ...
106 ) { 106 ) {
107 if (count == 0) return str; 107 if (count == 0) return str;
375 375
376 return n; 376 return n;
377 } 377 }
378 378
379 size_t cx_strsplit_a( 379 size_t cx_strsplit_a(
380 CxAllocator const *allocator, 380 const CxAllocator *allocator,
381 cxstring string, 381 cxstring string,
382 cxstring delim, 382 cxstring delim,
383 size_t limit, 383 size_t limit,
384 cxstring **output 384 cxstring **output
385 ) { 385 ) {
417 return cx_strsplit(cx_strcast(string), 417 return cx_strsplit(cx_strcast(string),
418 delim, limit, (cxstring *) output); 418 delim, limit, (cxstring *) output);
419 } 419 }
420 420
421 size_t cx_strsplit_ma( 421 size_t cx_strsplit_ma(
422 CxAllocator const *allocator, 422 const CxAllocator *allocator,
423 cxmutstr string, 423 cxmutstr string,
424 cxstring delim, 424 cxstring delim,
425 size_t limit, 425 size_t limit,
426 cxmutstr **output 426 cxmutstr **output
427 ) { 427 ) {
458 return -1; 458 return -1;
459 } 459 }
460 } 460 }
461 461
462 int cx_strcmp_p( 462 int cx_strcmp_p(
463 void const *s1, 463 const void *s1,
464 void const *s2 464 const void *s2
465 ) { 465 ) {
466 cxstring const *left = s1; 466 const cxstring *left = s1;
467 cxstring const *right = s2; 467 const cxstring *right = s2;
468 return cx_strcmp(*left, *right); 468 return cx_strcmp(*left, *right);
469 } 469 }
470 470
471 int cx_strcasecmp_p( 471 int cx_strcasecmp_p(
472 void const *s1, 472 const void *s1,
473 void const *s2 473 const void *s2
474 ) { 474 ) {
475 cxstring const *left = s1; 475 const cxstring *left = s1;
476 cxstring const *right = s2; 476 const cxstring *right = s2;
477 return cx_strcasecmp(*left, *right); 477 return cx_strcasecmp(*left, *right);
478 } 478 }
479 479
480 cxmutstr cx_strdup_a( 480 cxmutstr cx_strdup_a(
481 CxAllocator const *allocator, 481 const CxAllocator *allocator,
482 cxstring string 482 cxstring string
483 ) { 483 ) {
484 cxmutstr result = { 484 cxmutstr result = {
485 cxMalloc(allocator, string.length + 1), 485 cxMalloc(allocator, string.length + 1),
486 string.length 486 string.length
585 buf = next; 585 buf = next;
586 } 586 }
587 } 587 }
588 588
589 cxmutstr cx_strreplacen_a( 589 cxmutstr cx_strreplacen_a(
590 CxAllocator const *allocator, 590 const CxAllocator *allocator,
591 cxstring str, 591 cxstring str,
592 cxstring pattern, 592 cxstring pattern,
593 cxstring replacement, 593 cxstring replacement,
594 size_t replmax 594 size_t replmax
595 ) { 595 ) {
776 return cx_strtok_next(ctx, (cxstring *) token); 776 return cx_strtok_next(ctx, (cxstring *) token);
777 } 777 }
778 778
779 void cx_strtok_delim( 779 void cx_strtok_delim(
780 CxStrtokCtx *ctx, 780 CxStrtokCtx *ctx,
781 cxstring const *delim, 781 const cxstring *delim,
782 size_t count 782 size_t count
783 ) { 783 ) {
784 ctx->delim_more = delim; 784 ctx->delim_more = delim;
785 ctx->delim_more_count = count; 785 ctx->delim_more_count = count;
786 } 786 }

mercurial