IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 8, 2007, 2:47:41 PM (19 years ago)
Author:
Paul Price
Message:

Adding some additional memory instrumentation. Adding warning about use of psStringAppend under certain conditions; can't trap all the dangerous uses, but can catch the really really dangerous ones.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psString.c

    r15502 r15523  
    1313 *  @author David Robbins, MHPCC
    1414 *
    15  *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2007-11-08 04:22:23 $
     15 *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2007-11-09 00:47:41 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    144144    ssize_t         tailLength = 0;         // length of string to append
    145145
     146    if (*dest && psMemGetRefCounter(*dest) > 1) {
     147        psWarning("Appending to a string with multiple reference counts may corrupt memory!");
     148    }
     149
    146150    if (*dest) {
    147151        oldLength = strlen(*dest);
     
    218222    char            *oldDest;           // copy of original string
    219223
     224    if (*dest && psMemGetRefCounter(*dest) > 1) {
     225        psWarning("Appending to a string with multiple reference counts may corrupt memory!");
     226    }
     227
    220228    if (!*dest) {
    221229        // makes the string backup and concatination pointless
     
    270278// NULL input string returns empty (not NULL) list
    271279// NULL splitters is an error
    272 psList *psStringSplit(const char *string,
    273                       const char *splitters,
    274                       bool multipleAreSignificant)
     280psList *p_psStringSplit(const char *file,
     281                        unsigned int lineno,
     282                        const char *func,
     283                        const char *string,
     284                        const char *splitters,
     285                        bool multipleAreSignificant)
    275286{
    276287    PS_ASSERT_STRING_NON_EMPTY(splitters, NULL);
    277288
    278     psList *values = psListAlloc(NULL); // The list of values to return
     289    psList *values = p_psListAlloc(file, lineno, func, NULL); // The list of values to return
    279290    // An input NULL string should not generate an error: it is a valid case
    280291    if (string == NULL) {
     
    293304
    294305        // Copy the current word
    295         psString word = psStringNCopy(current, next - current);
     306        psString word = p_psStringNCopy(file, lineno, func, current, next - current);
    296307        psListAdd(values, PS_LIST_TAIL, word);
    297308        psFree(word);
     
    302313    if (strlen(current) > 0) {
    303314        // Copy the last word
    304         psString word = psStringCopy(current);
     315        psString word = p_psStringCopy(file, lineno, func, current);
    305316        (void)psListAdd(values, PS_LIST_TAIL, word);
    306317        psFree(word);
Note: See TracChangeset for help on using the changeset viewer.