Ignore:
Timestamp:
Feb 26, 2002, 9:28:01 PM (23 years ago)
Author:
umoeller
Message:

Misc minor fixes.

File:
1 edited

Legend:

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

    r141 r144  
    1515 *      a char* pointer pointing to heap memory, which is managed
    1616 *      automatically.
     17 *
     18 *      Besides being convenient, these functions are highly
     19 *      optimized to use as few strlen's and memcpy's as
     20 *      possible.
    1721 *
    1822 *      Using these functions has the following advantages:
     
    8589
    8690/*
    87  *      Copyright (C) 1999-2001 Ulrich M”ller.
     91 *      Copyright (C) 1999-2002 Ulrich M”ller.
    8892 *      This file is part of the "XWorkplace helpers" source package.
    8993 *      This is free software; you can redistribute it and/or modify
     
    210214 *
    211215 +          XSTRING str;
    212  +          xstrInitSet(&str, strdup("blah"));
     216 +          xstrInitSet(&str, strdup("blah"), 0);
    213217 *
    214218 *@@added V0.9.16 (2002-01-13) [umoeller]
    215219 */
    216220
    217 void xstrInitSet2(PXSTRING pxstr,
    218                   PSZ pszNew,
    219                   ULONG ulNewLength)
     221void xstrInitSet2(PXSTRING pxstr,           // in/out: string
     222                  PSZ pszNew,               // in: malloc'd string to load pxstr with
     223                  ULONG ulNewLength)        // in: length of pszNew or 0 to run strlen()
    220224{
    221225    if (!pszNew)
     
    326330        if (pcszSource)
    327331        {
    328             pxstr->ulLength = strlen(pcszSource);
    329 
    330             if (pxstr->ulLength)
     332            if (pxstr->ulLength = strlen(pcszSource))
    331333            {
    332334                // we do have a source string:
     
    542544
    543545    xstrClear(pxstr);
    544     pxstr->psz = pszNew;
    545     if (pszNew)
     546    if (pxstr->psz = pszNew)
    546547    {
    547548        if (!ulNewLength)
     
    576577 *      as necessary.
    577578 *
    578  *      If pxstr contains something, its contents are destroyed.
     579 *      If pxstr contains something, its contents are overwritten.
    579580 *
    580581 *      With ulSourceLength, specify the length of pcszSource
     
    10101011            // now overwrite "found" in the middle
    10111012            if (cReplaceWithLen)
    1012             {
    10131013                memcpy(pFound,
    10141014                       pcszReplaceWith,
    10151015                       cReplaceWithLen);        // no null terminator
    1016             }
    10171016
    10181017            // that's it; adjust the string length now
Note: See TracChangeset for help on using the changeset viewer.