IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 14, 2006, 4:50:51 PM (20 years ago)
Author:
Paul Price
Message:

Changing psAlloc to psStringAlloc so that psMemCheckString will work.

File:
1 edited

Legend:

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

    r7905 r7912  
    1313 *  @author David Robbins, MHPCC
    1414 *
    15  *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2006-07-14 20:06:43 $
     15 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-07-15 02:50:51 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5656{
    5757    // Pass through NULL values!
    58 
    59     // Allocate memory using psAlloc function
     58    if (!string) {
     59        return NULL;
     60    }
     61    psString output = psStringAlloc(strlen(string) + 1); // Output string
    6062    // Copy input string to memory just allocated
    61     // Return the copy
    62     return string ? strcpy(psAlloc(strlen(string) + 1), string) : NULL;
     63    return strcpy(output, string);
    6364}
    6465
     
    6768{
    6869    PS_ASSERT_PTR_NON_NULL(string, NULL);
    69     char *returnValue = NULL;
     70
     71    // Pass through NULL values
     72    if (!string) {
     73        return NULL;
     74    }
    7075
    7176    // Check the number of characters to copy is non-negative
     
    7782        return NULL;
    7883    }
    79     // Allocate memory using psAlloc function - nChar bytes
     84
    8085    // Copy input string to memory allocated up to nChar characters
    81     // Return the copy
    82     // Pass through NULL values
    83     returnValue =
    84               string ? strncpy(psAlloc((size_t) nChar + 1), string, (size_t) nChar)
    85               : NULL;
     86    psString output = psStringAlloc((size_t) nChar + 1);
     87    output = strncpy(output, string, (size_t) nChar);
    8688
    8789    // Ensure the last byte is NULL character
    88     returnValue[nChar] = '\0';
     90    output[nChar] = '\0';
    8991
    9092    // Return the string pointer
    91     return returnValue;
     93    return output;
    9294}
    9395
     
    279281
    280282        // this is safe since we will subtract strlen(key) elements from input
    281         psString output = psAlloc(strlen(input) + replaceLength + 1); // Output string
     283        psString output = psStringAlloc(strlen(input) + replaceLength + 1); // Output string
    282284        int Nc = p - input;             // Number of characters to copy
    283285
Note: See TracChangeset for help on using the changeset viewer.