Ignore:
Timestamp:
Feb 23, 2001, 7:50:07 AM (24 years ago)
Author:
umoeller
Message:

Misc. fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/xstring.c

    r38 r39  
    376376 *      With ulSourceLength, specify the length of pcszSource.
    377377 *      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.
    381385 *
    382386 *      Returns the length of the new string (excluding the null
     
    396400 *@@changed V0.9.9 (2001-01-28) [lafaix]: fixed memory leak and NULL source behavior
    397401 *@@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
    398403 */
    399404
     
    432437        // else: we have enough memory
    433438
    434         // strcpy(pxstr->psz, pcszSource);
    435439        memcpy(pxstr->psz,
    436440               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
    438446    }
    439447    else
     
    480488 *      With ulSourceLength, specify the length of pcszSource.
    481489 *      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.
    485497 *
    486498 *      Returns the length of the new string (excluding the null
     
    508520 *@@changed V0.9.7 (2000-12-10) [umoeller]: return value was wrong
    509521 *@@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
    510523 */
    511524
     
    559572                memcpy(pxstr->psz + pxstr->ulLength,
    560573                       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
    562580
    563581                // in all cases, set new length
Note: See TracChangeset for help on using the changeset viewer.