IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12517


Ignore:
Timestamp:
Mar 21, 2007, 11:37:58 AM (19 years ago)
Author:
jhoblitt
Message:

change p_psStringNCopy() p_psStringAlloc() accept string size as type size_t

Location:
trunk/psLib/src/sys
Files:
2 edited

Legend:

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

    r12286 r12517  
    1313 *  @author David Robbins, MHPCC
    1414 *
    15  *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2007-03-07 00:17:48 $
     15 *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2007-03-21 21:37:58 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4343                         unsigned int lineno,
    4444                         const char *func,
    45                          long nChar)
     45                         size_t nChar)
    4646{
    4747    if (nChar < 1) {
     
    8585                         const char *func,
    8686                         const char *string,
    87                          unsigned int nChar)
     87                         size_t nChar)
    8888{
    8989    // Pass through NULL values
     
    9393
    9494    // Check the number of characters to copy is non-negative
    95     if (nChar == UINT_MAX) {
     95    if (nChar < 0) {
    9696        // Log error message and return NULL
    9797        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    98                 _("Can not copy a negative number of characters (%d)."),
     98                _("Can not copy a negative number of characters (%zd)."),
    9999                nChar);
    100100        return NULL;
     
    102102
    103103    // Copy input string to memory allocated up to nChar characters
    104     psString output = p_psStringAlloc(file, lineno, func, (size_t) nChar + 1);
    105     output = strncpy(output, string, (size_t) nChar);
     104    psString output = p_psStringAlloc(file, lineno, func, nChar + 1);
     105    output = strncpy(output, string, nChar);
    106106
    107107    // Ensure the last byte is NULL character
  • trunk/psLib/src/sys/psString.h

    r12296 r12517  
    1111 * @author Joshua Hoblitt, University of Hawaii
    1212 *
    13  * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
    14  * @date $Date: 2007-03-07 22:30:23 $
     13 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
     14 * @date $Date: 2007-03-21 21:37:58 $
    1515 *
    1616 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4646#ifdef DOXYGEN
    4747psString psStringAlloc(
    48     long nChar                         ///< Size of psString to allocate.
     48    size_t nChar                        ///< Size of psString to allocate.
    4949);
    5050#else // ifdef DOXYGEN
     
    5353    unsigned int lineno,                ///< Line number of caller
    5454    const char *func,                   ///< Function name of caller
    55     long nChar                         ///< Size of psString to allocate.
     55    size_t nChar                        ///< Size of psString to allocate.
    5656);
    5757#define psStringAlloc(nChar) \
     
    110110#ifdef DOXYGEN
    111111psString psStringNCopy(
    112     const char *string,                ///< Input string of characters to copy
    113     unsigned int nChar                 ///< Number of bytes to allocate for string copy
     112    const char *string,                 ///< Input string of characters to copy
     113    size_t nChar                        ///< Number of bytes to allocate for string copy
    114114);
    115115#else // ifdef DOXYGEN
     
    119119    const char *func,                   ///< Function name of caller
    120120    const char *string,                 ///< Input string of characters to copy
    121     unsigned int nChar                  ///< Number of bytes to allocate for string copy
     121    size_t nChar                        ///< Number of bytes to allocate for string copy
    122122);
    123123#define psStringNCopy(string, nChar) \
Note: See TracChangeset for help on using the changeset viewer.