Changeset 6278 for trunk/psLib/src/sys
- Timestamp:
- Feb 1, 2006, 10:40:56 AM (20 years ago)
- Location:
- trunk/psLib/src/sys
- Files:
-
- 2 edited
-
psString.c (modified) (6 diffs)
-
psString.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psString.c
r6218 r6278 13 13 * @author David Robbins, MHPCC 14 14 * 15 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $16 * @date $Date: 2006-0 1-27 01:49:05$15 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2006-02-01 20:40:56 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 31 31 psString psStringCopy(const char *string) 32 32 { 33 PS_ASSERT_PTR_NON_NULL(string, NULL); 33 34 // Allocate memory using psAlloc function 34 35 // Copy input string to memory just allocated 35 36 // Return the copy 36 return strcpy(psAlloc(strlen(string) + 1), string); 37 // Pass through NULL values 38 return string ? strcpy(psAlloc(strlen(string) + 1), string) : NULL; 37 39 } 38 40 … … 40 42 unsigned int nChar) 41 43 { 44 PS_ASSERT_PTR_NON_NULL(string, NULL); 42 45 char *returnValue = NULL; 43 46 … … 53 56 // Copy input string to memory allocated up to nChar characters 54 57 // Return the copy 55 returnValue = strncpy(psAlloc((size_t) nChar + 1), string, (size_t) nChar); 58 // Pass through NULL values 59 returnValue = 60 string ? strncpy(psAlloc((size_t) nChar + 1), string, (size_t) nChar) 61 : NULL; 56 62 57 63 // Ensure the last byte is NULL character … … 66 72 ...) 67 73 { 74 PS_ASSERT_PTR_NON_NULL(format, 0); 68 75 va_list args; 69 76 size_t length; // complete string length (sans \0) … … 113 120 ...) 114 121 { 122 PS_ASSERT_PTR_NON_NULL(format, 0); 115 123 va_list args; 116 124 size_t length; // complete string length (sans \0) -
trunk/psLib/src/sys/psString.h
r6201 r6278 14 14 * @author David Robbins, MHPCC 15 15 * 16 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $17 * @date $Date: 2006-0 1-26 05:31:54$16 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2006-02-01 20:40:56 $ 18 18 * 19 19 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 38 38 /** Copies the input string 39 39 * 40 * This function shall allocate memory to the length of the input string 41 * plus one and copy the input string to the newly allocated memory. 40 * This function shall allocate memory to the length of the input string plus 41 * one and copy the input string to the newly allocated memory. If 'string' 42 * is 'NULL' then 'NULL' is returned. 42 43 * 43 44 * @return psString: Copy of input string … … 55 56 * string will be a substring of the input string. If the input string 56 57 * is smaller than nChar bytes then the remaining bytes allocated will 57 * be set to NULL. 58 * be set to NULL. If 'string' is 'NULL' then 'NULL' is returned. 58 59 * 59 60 * @return psString: Copy of input string
Note:
See TracChangeset
for help on using the changeset viewer.
