Changeset 91 for trunk/src/helpers/stringh.c
- Timestamp:
- Aug 2, 2001, 10:36:35 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/stringh.c
r81 r91 52 52 #include "setup.h" // code generation and debugging options 53 53 54 #define DONT_REPLACE_STRINGH_MALLOC 54 55 #include "helpers\stringh.h" 55 56 #include "helpers\xstring.h" // extended string helpers … … 68 69 69 70 /* 71 *@@ strcpy: 72 * like strdup, but this one doesn't crash if string2 is NULL, 73 * but sets the first byte in string1 to \0 instead. 74 * 75 *@@added V0.9.14 (2001-08-01) [umoeller] 76 */ 77 78 PSZ strhcpy(PSZ string1, const char *string2) 79 { 80 if (string2) 81 return (strcpy(string1, string2)); 82 83 *string1 = '\0'; 84 return (string1); 85 } 86 87 #ifdef __DEBUG_MALLOC_ENABLED__ 88 89 /* 70 90 *@@ strhdup: 71 * like strdup, but this one 72 * doesn't crash if pszSource is NULL, 91 * memory debug version of strhdup. 92 * 93 *@@added V0.9.0 [umoeller] 94 */ 95 96 PSZ strhdupDebug(const char *pszSource, 97 const char *pcszSourceFile, 98 unsigned long ulLine, 99 const char *pcszFunction) 100 { 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); 112 } 113 114 #endif // __DEBUG_MALLOC_ENABLED__ 115 116 /* 117 *@@ strhdup: 118 * like strdup, but this one doesn't crash if pszSource is NULL, 73 119 * but returns NULL also. 74 120 * … … 248 294 } 249 295 296 #ifdef __DEBUG_MALLOC_ENABLED__ 297 298 /* 299 *@@ strhSubstrDebug: 300 * memory debug version of strhSubstr. 301 * 302 *@@added V0.9.14 (2001-08-01) [umoeller] 303 */ 304 305 PSZ strhSubstrDebug(const char *pBegin, // in: first char 306 const char *pEnd, // in: last char (not included) 307 const char *pcszSourceFile, 308 unsigned long ulLine, 309 const char *pcszFunction) 310 { 311 PSZ pszSubstr = NULL; 312 313 if (pEnd > pBegin) // V0.9.9 (2001-04-04) [umoeller] 314 { 315 ULONG cbSubstr = (pEnd - pBegin); 316 if (pszSubstr = (PSZ)memdMalloc(cbSubstr + 1, 317 pcszSourceFile, 318 ulLine, 319 pcszFunction)) 320 { 321 // strhncpy0(pszSubstr, pBegin, cbSubstr); 322 memcpy(pszSubstr, pBegin, cbSubstr); // V0.9.9 (2001-04-04) [umoeller] 323 *(pszSubstr + cbSubstr) = '\0'; 324 } 325 } 326 327 return (pszSubstr); 328 } 329 330 #endif // __DEBUG_MALLOC_ENABLED__ 331 250 332 /* 251 333 *@@ strhSubstr: … … 274 356 { 275 357 ULONG cbSubstr = (pEnd - pBegin); 276 pszSubstr = (PSZ)malloc(cbSubstr + 1); 277 if (pszSubstr) 358 if (pszSubstr = (PSZ)malloc(cbSubstr + 1)) 278 359 { 279 // strhncpy0(pszSubstr, pBegin, cbSubstr);280 360 memcpy(pszSubstr, pBegin, cbSubstr); // V0.9.9 (2001-04-04) [umoeller] 281 361 *(pszSubstr + cbSubstr) = '\0';
Note:
See TracChangeset
for help on using the changeset viewer.