Changeset 12517
- Timestamp:
- Mar 21, 2007, 11:37:58 AM (19 years ago)
- Location:
- trunk/psLib/src/sys
- Files:
-
- 2 edited
-
psString.c (modified) (5 diffs)
-
psString.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psString.c
r12286 r12517 13 13 * @author David Robbins, MHPCC 14 14 * 15 * @version $Revision: 1.5 3$ $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 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 43 43 unsigned int lineno, 44 44 const char *func, 45 longnChar)45 size_t nChar) 46 46 { 47 47 if (nChar < 1) { … … 85 85 const char *func, 86 86 const char *string, 87 unsigned int nChar)87 size_t nChar) 88 88 { 89 89 // Pass through NULL values … … 93 93 94 94 // Check the number of characters to copy is non-negative 95 if (nChar == UINT_MAX) {95 if (nChar < 0) { 96 96 // Log error message and return NULL 97 97 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)."), 99 99 nChar); 100 100 return NULL; … … 102 102 103 103 // 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); 106 106 107 107 // Ensure the last byte is NULL character -
trunk/psLib/src/sys/psString.h
r12296 r12517 11 11 * @author Joshua Hoblitt, University of Hawaii 12 12 * 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 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 46 46 #ifdef DOXYGEN 47 47 psString psStringAlloc( 48 long nChar///< Size of psString to allocate.48 size_t nChar ///< Size of psString to allocate. 49 49 ); 50 50 #else // ifdef DOXYGEN … … 53 53 unsigned int lineno, ///< Line number of caller 54 54 const char *func, ///< Function name of caller 55 long nChar///< Size of psString to allocate.55 size_t nChar ///< Size of psString to allocate. 56 56 ); 57 57 #define psStringAlloc(nChar) \ … … 110 110 #ifdef DOXYGEN 111 111 psString psStringNCopy( 112 const char *string, ///< Input string of characters to copy113 unsigned int nChar///< Number of bytes to allocate for string copy112 const char *string, ///< Input string of characters to copy 113 size_t nChar ///< Number of bytes to allocate for string copy 114 114 ); 115 115 #else // ifdef DOXYGEN … … 119 119 const char *func, ///< Function name of caller 120 120 const char *string, ///< Input string of characters to copy 121 unsigned int nChar///< Number of bytes to allocate for string copy121 size_t nChar ///< Number of bytes to allocate for string copy 122 122 ); 123 123 #define psStringNCopy(string, nChar) \
Note:
See TracChangeset
for help on using the changeset viewer.
