Changeset 39 for trunk/src/helpers/xstring.c
- Timestamp:
- Feb 23, 2001, 7:50:07 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/xstring.c
r38 r39 376 376 * With ulSourceLength, specify the length of pcszSource. 377 377 * If you specify 0, this function will run strlen(pcszSource) 378 * itself. If you already know the length of pcszSource (or 379 * only want to copy a substring), you can speed this function 380 * up a bit this way. 378 * itself. 379 * 380 * If you already know the length of pcszSource, you can 381 * speed this function up a bit this way. 382 * 383 * You are required to specify ulSourceLength if you only want 384 * to copy a substring, or pcszSource is not zero-terminated. 381 385 * 382 386 * Returns the length of the new string (excluding the null … … 396 400 *@@changed V0.9.9 (2001-01-28) [lafaix]: fixed memory leak and NULL source behavior 397 401 *@@changed V0.9.9 (2001-02-14) [umoeller]: fixed NULL target crash 402 *@@changed V0.9.9 (2001-02-16) [umoeller]: now supporting non-zero-terminated pcszSource 398 403 */ 399 404 … … 432 437 // else: we have enough memory 433 438 434 // strcpy(pxstr->psz, pcszSource);435 439 memcpy(pxstr->psz, 436 440 pcszSource, 437 ulSourceLength + 1); // V0.9.9 (2001-01-31) [umoeller] 441 ulSourceLength); 442 *(pxstr->psz + ulSourceLength) = '\0'; 443 // V0.9.9 (2001-02-16) [umoeller] 444 // we must do this or otherwise we require pcszSource 445 // to be zero-terminated... not a good idea 438 446 } 439 447 else … … 480 488 * With ulSourceLength, specify the length of pcszSource. 481 489 * If you specify 0, this function will run strlen(pcszSource) 482 * itself. If you already know the length of pcszSource (or 483 * only want to copy a substring), you can speed this function 484 * up a bit this way. 490 * itself. 491 * 492 * If you already know the length of pcszSource, you can 493 * speed this function up a bit this way. 494 * 495 * You are required to specify ulSourceLength if you only want 496 * to copy a substring, or pcszSource is not zero-terminated. 485 497 * 486 498 * Returns the length of the new string (excluding the null … … 508 520 *@@changed V0.9.7 (2000-12-10) [umoeller]: return value was wrong 509 521 *@@changed V0.9.7 (2001-01-15) [umoeller]: added ulSourceLength 522 *@@changed V0.9.9 (2001-02-16) [umoeller]: now supporting non-zero-terminated pcszSource 510 523 */ 511 524 … … 559 572 memcpy(pxstr->psz + pxstr->ulLength, 560 573 pcszSource, 561 ulSourceLength + 1); // null terminator 574 ulSourceLength); // null terminator 575 576 *(pxstr->psz + pxstr->ulLength + ulSourceLength) = '\0'; 577 // V0.9.9 (2001-02-16) [umoeller] 578 // we must do this or otherwise we require pcszSource 579 // to be zero-terminated... not a good idea 562 580 563 581 // in all cases, set new length
Note:
See TracChangeset
for help on using the changeset viewer.