IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.