Ignore:
Timestamp:
May 22, 2001, 7:18:41 PM (24 years ago)
Author:
umoeller
Message:

misc updates

File:
1 edited

Legend:

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

    r65 r71  
    285285 *@@added V0.9.7 (2001-01-07) [umoeller]
    286286 *@@changed V0.9.9 (2001-03-09) [umoeller]: now using ulDelta
     287 *@@changed V0.9.12 (2001-05-21) [umoeller]: now reporting error on realloc fail
    287288 */
    288289
     
    318319        // this gives the C runtime a chance to expand the
    319320        // existing block
    320         pxstr->psz = (PSZ)realloc(pxstr->psz, cbAllocate);
     321        if (pxstr->psz = (PSZ)realloc(pxstr->psz, cbAllocate))
    321322                    // if pxstr->psz is NULL, realloc behaves like malloc
    322         pxstr->cbAllocated = cbAllocate;
     323            pxstr->cbAllocated = cbAllocate;
    323324                // ulLength is unchanged
     325        else
     326            // error: V0.9.12 (2001-05-21) [umoeller]
     327            pxstr->cbAllocated = 0;
    324328    }
    325329    // else: we have enough memory
     
    448452 *@@changed V0.9.9 (2001-02-16) [umoeller]: now supporting non-zero-terminated pcszSource
    449453 *@@changed V0.9.9 (2001-03-09) [umoeller]: now using xstrReserve
     454 *@@changed V0.9.12 (2001-05-21) [umoeller]: added xstrReserve error checking
    450455 */
    451456
     
    470475    {
    471476        // we do have a source string:
    472         xstrReserve(pxstr,
    473                     // required memory:
    474                     ulSourceLength + 1);
    475 
    476         memcpy(pxstr->psz,
    477                pcszSource,
    478                ulSourceLength);
    479         *(pxstr->psz + ulSourceLength) = '\0';
    480                 // V0.9.9 (2001-02-16) [umoeller]
    481                 // we must do this or otherwise we require pcszSource
    482                 // to be zero-terminated... not a good idea
     477        if (xstrReserve(pxstr,
     478                        // required memory:
     479                        ulSourceLength + 1))
     480        {
     481            memcpy(pxstr->psz,
     482                   pcszSource,
     483                   ulSourceLength);
     484            *(pxstr->psz + ulSourceLength) = '\0';
     485                    // V0.9.9 (2001-02-16) [umoeller]
     486                    // we must do this or otherwise we require pcszSource
     487                    // to be zero-terminated... not a good idea
     488        }
     489        else
     490            pxstr->ulLength = 0;        // error V0.9.12 (2001-05-21) [umoeller]
    483491    }
    484492    else
Note: See TracChangeset for help on using the changeset viewer.