Changeset 116 for trunk/src/helpers/stringh.c
- Timestamp:
- Nov 1, 2001, 6:43:18 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/stringh.c
r108 r116 95 95 96 96 PSZ strhdupDebug(const char *pszSource, 97 unsigned long *pulLength, 97 98 const char *pcszSourceFile, 98 99 unsigned long ulLine, 99 100 const char *pcszFunction) 100 101 { 101 if (pszSource) 102 { 103 PSZ p = (PSZ)memdMalloc(strlen(pszSource) + 1, 104 pcszSourceFile, 105 ulLine, 106 pcszFunction); 107 strcpy(p, pszSource); 108 return (p); 109 } 110 else 111 return (0); 102 PSZ pszReturn = NULL; 103 ULONG ulLength = 0; 104 105 if ( (pcszSource) 106 && (ulLength = strlen(pcszSource)) 107 ) 108 { 109 if (pszReturn = (PSZ)memdMalloc(ulLength + 1, 110 pcszSourceFile, 111 ulLine, 112 pcszFunction)) 113 memcpy(pszReturn, pcszSource, ulLength + 1); 114 } 115 116 if (pulLength) 117 *pulLength = ulLength; 118 119 return (pszReturn); 112 120 } 113 121 … … 116 124 /* 117 125 *@@ strhdup: 118 * like strdup, but this one doesn't crash if pszSource is NULL, 119 * but returns NULL also. 126 * like strdup, but this one doesn't crash if pszSource 127 * is NULL, but returns NULL also. In addition, this 128 * can report the length of the string (V0.9.16). 120 129 * 121 130 *@@added V0.9.0 [umoeller] 122 */ 123 124 PSZ strhdup(const char *pszSource) 125 { 126 if (pszSource) 127 return (strdup(pszSource)); 128 else 129 return (0); 131 *@@changed V0.9.16 (2001-10-25) [umoeller]: added pulLength 132 */ 133 134 PSZ strhdup(const char *pcszSource, 135 unsigned long *pulLength) // out: length of string excl. null terminator (ptr can be NULL) 136 { 137 PSZ pszReturn = NULL; 138 ULONG ulLength = 0; 139 140 if ( (pcszSource) 141 && (ulLength = strlen(pcszSource)) 142 ) 143 { 144 if (pszReturn = (PSZ)malloc(ulLength + 1)) 145 memcpy(pszReturn, pcszSource, ulLength + 1); 146 } 147 148 if (pulLength) 149 *pulLength = ulLength; 150 151 return (pszReturn); 130 152 } 131 153
Note:
See TracChangeset
for help on using the changeset viewer.