Changeset 22736 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Sep 3, 2009 11:32:59 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/string.cpp
r21337 r22736 65 65 RTDECL(char *) RTStrDup(const char *pszString) 66 66 { 67 Assert (VALID_PTR(pszString));67 AssertPtr(pszString); 68 68 size_t cch = strlen(pszString) + 1; 69 69 char *psz = (char *)RTMemAlloc(cch); … … 85 85 RTDECL(int) RTStrDupEx(char **ppszString, const char *pszString) 86 86 { 87 Assert (VALID_PTR(ppszString));88 Assert (VALID_PTR(pszString));87 AssertPtr(ppszString); 88 AssertPtr(pszString); 89 89 90 90 size_t cch = strlen(pszString) + 1; … … 100 100 RT_EXPORT_SYMBOL(RTStrDupEx); 101 101 102 103 /** 104 * Allocates a new copy of the given UTF-8 substring. 105 * 106 * @returns Pointer to the allocated UTF-8 substring. 107 * @param pszString UTF-8 string to duplicate. 108 * @param cchMax The max number of chars to duplicate, not counting 109 * the terminator. 110 */ 111 RTDECL(char *) RTStrDupN(const char *pszString, size_t cchMax) 112 { 113 AssertPtr(pszString); 114 char *pszEnd = (char *)memchr(pszString, '\0', cchMax); 115 size_t cch = pszEnd ? (uintptr_t)pszEnd - (uintptr_t)pszString : cchMax; 116 char *pszDst = (char *)RTMemAlloc(cch); 117 if (pszDst) 118 { 119 memcpy(pszDst, pszString, cch); 120 pszDst[cch] = '\0'; 121 } 122 return pszDst; 123 } 124 RT_EXPORT_SYMBOL(RTStrDupN); 125 126 127
Note:
See TracChangeset
for help on using the changeset viewer.