Changeset 187 for trunk/src/helpers/xstring.c
- Timestamp:
- Jul 8, 2002, 6:53:23 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/xstring.c
r154 r187 34 34 * iterative appends, you can pre-allocate memory to 35 35 * avoid excessive reallocations. 36 * 37 * These functions are also used internally by the 38 * WarpIN BSString class (and related classes). 36 39 * 37 40 * Usage: … … 139 142 { 140 143 memset(pxstr, 0, sizeof(XSTRING)); 144 141 145 if (ulPreAllocate) 142 146 { … … 186 190 { 187 191 memset(pxstr, 0, sizeof(XSTRING)); 192 188 193 if (ulPreAllocate) 189 194 { … … 362 367 if (pxstr->psz) 363 368 free(pxstr->psz); 369 364 370 memset(pxstr, 0, sizeof(XSTRING)); 365 371 } … … 441 447 // else: we have enough memory 442 448 443 return (pxstr->cbAllocated);449 return pxstr->cbAllocated; 444 450 } 445 451 … … 485 491 xstrInit(pxstr, ulPreAllocate); 486 492 487 return (pxstr);493 return pxstr; 488 494 } 489 495 … … 542 548 { 543 549 if (!pxstr) 544 return (0); // V0.9.9 (2001-02-14) [umoeller]550 return 0; // V0.9.9 (2001-02-14) [umoeller] 545 551 546 552 xstrClear(pxstr); … … 556 562 // else null string: cbAllocated and ulLength are 0 already 557 563 558 return (pxstr->ulLength);564 return pxstr->ulLength; 559 565 } 560 566 … … 570 576 PSZ pszNew) // in: heap PSZ to use 571 577 { 572 return (xstrset2(pxstr, pszNew, 0));578 return xstrset2(pxstr, pszNew, 0); 573 579 } 574 580 … … 621 627 622 628 ULONG xstrcpy(PXSTRING pxstr, // in/out: string 623 PCSZ pcszSource, // in: source, can be NULL629 PCSZ pcszSource, // in: source, can be NULL 624 630 ULONG ulSourceLength) // in: length of pcszSource or 0 625 631 { 626 632 if (!pxstr) 627 return (0); // V0.9.9 (2001-02-14) [umoeller]633 return 0; // V0.9.9 (2001-02-14) [umoeller] 628 634 629 635 if (pcszSource) … … 647 653 pcszSource, 648 654 ulSourceLength); 649 *(pxstr->psz + ulSourceLength)= '\0';655 pxstr->psz[ulSourceLength] = '\0'; 650 656 // V0.9.9 (2001-02-16) [umoeller] 651 657 // we must do this or otherwise we require pcszSource … … 670 676 pxstr->ulLength = ulSourceLength; 671 677 672 return (pxstr->ulLength);678 return pxstr->ulLength; 673 679 } 674 680 … … 684 690 { 685 691 if (!pcstrSource) 686 return (0);687 688 return (xstrcpy(pxstr, pcstrSource->psz, pcstrSource->ulLength));692 return 0; 693 694 return xstrcpy(pxstr, pcstrSource->psz, pcstrSource->ulLength); 689 695 } 690 696 … … 758 764 ulSourceLength); 759 765 760 *(pxstr->psz + pxstr->ulLength + ulSourceLength)= '\0';766 pxstr->psz[pxstr->ulLength + ulSourceLength] = '\0'; 761 767 // V0.9.9 (2001-02-16) [umoeller] 762 768 // we must do this or otherwise we require pcszSource … … 774 780 } 775 781 776 return (ulrc);782 return ulrc; 777 783 } 778 784 … … 816 822 if ((pxstr) && (c)) 817 823 { 818 // ULONG ulSourceLength = 1;819 824 // 1) memory management 820 825 xstrReserve(pxstr, … … 833 838 } // end if ((pxstr) && (c)) 834 839 835 return (ulrc);840 return ulrc; 836 841 } 837 842 … … 847 852 { 848 853 if (!pcstrSource) 849 return (0);850 851 return (xstrcat(pxstr,852 853 pcstrSource->ulLength));854 return 0; 855 856 return xstrcat(pxstr, 857 pcstrSource->psz, 858 pcstrSource->ulLength); 854 859 } 855 860 … … 1023 1028 } // end checks 1024 1029 1025 return (ulrc);1030 return ulrc; 1026 1031 } 1027 1032 … … 1094 1099 } 1095 1100 1096 return (pReturn);1101 return pReturn; 1097 1102 } 1098 1103 … … 1210 1215 } // end if ((pxstr) && (pstrSearch) && (pstrReplace)) 1211 1216 1212 return (ulrc);1217 return ulrc; 1213 1218 } 1214 1219 … … 1246 1251 xstrInitSet(&xstrReplace, (PSZ)pcszReplace); 1247 1252 1248 return (xstrFindReplace(pxstr, pulOfs, &xstrFind, &xstrReplace, ShiftTable, &fRepeat));1253 return xstrFindReplace(pxstr, pulOfs, &xstrFind, &xstrReplace, ShiftTable, &fRepeat); 1249 1254 } 1250 1255 … … 1325 1330 */ 1326 1331 1327 ULONG xstrEncode(PXSTRING pxstr, 1332 ULONG xstrEncode(PXSTRING pxstr, // in/out: string to convert 1328 1333 PCSZ pcszEncode) // in: characters to encode (e.g. "%,();=") 1329 1334 { … … 1383 1388 } 1384 1389 1385 return (ulrc);1390 return ulrc; 1386 1391 } 1387 1392 … … 1464 1469 } 1465 1470 1466 return (ulrc);1471 return ulrc; 1467 1472 } 1468 1473 … … 1476 1481 ULONG xstrDecode(PXSTRING pxstr) 1477 1482 { 1478 return (xstrDecode2(pxstr, '%'));1483 return xstrDecode2(pxstr, '%'); 1479 1484 } 1480 1485 … … 1683 1688 printf("New string is: \"%s\" (%d/%d/%d)\n", str.psz, str.ulLength, str.cbAllocated, str.ulDelta); 1684 1689 1685 return (0);1690 return 0; 1686 1691 } */ 1687 1692
Note:
See TracChangeset
for help on using the changeset viewer.