IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15523


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.

Location:
trunk/psLib/src/sys
Files:
2 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);
  • trunk/psLib/src/sys/psString.h

    r14679 r15523  
    1111 * @author Joshua Hoblitt, University of Hawaii
    1212 *
    13  * @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
    14  * @date $Date: 2007-08-27 23:24:21 $
     13 * @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
     14 * @date $Date: 2007-11-09 00:47:41 $
    1515 *
    1616 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    242242 *  @return psList*:    The list of (split) psStrings.
    243243 */
     244#ifdef DOXYGEN
    244245psList *psStringSplit(
    245246    const char *string,                ///< String to split
     
    247248    bool multipleAreSignificant        ///< Are multiple occurences significant?
    248249);
    249 
     250#else // ifdef DOXYGEN
     251psList *p_psStringSplit(
     252    const char *file,                   ///< File of caller
     253    unsigned int lineno,                ///< Line number of caller
     254    const char *func,                   ///< Function name of caller
     255    const char *string,                ///< String to split
     256    const char *splitters,             ///< Characters on which to split
     257    bool multipleAreSignificant        ///< Are multiple occurences significant?
     258    );
     259#define psStringSplit(string, splitters, multiple) \
     260      p_psStringSplit(__FILE__, __LINE__, __func__, string, splitters, multiple)
     261#endif // ifdef DOXYGEN
    250262
    251263/** Procedure to split the input string into a psArray of psStrings.
Note: See TracChangeset for help on using the changeset viewer.