Changeset 93057 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Dec 22, 2021 2:21:25 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 149064
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/stringalloc.cpp
r83979 r93057 116 116 117 117 118 RTDECL(int) RTStrDupExTag(char **ppsz String, const char *pszString, const char *pszTag)118 RTDECL(int) RTStrDupExTag(char **ppszCopy, const char *pszString, const char *pszTag) 119 119 { 120 120 #if defined(__cplusplus) 121 AssertPtr(ppsz String);121 AssertPtr(ppszCopy); 122 122 AssertPtr(pszString); 123 123 #endif 124 124 125 size_t cch = strlen(pszString) + 1; 126 char *psz = (char *)RTMemAllocTag(cch, pszTag); 127 if (psz) 128 { 129 memcpy(psz, pszString, cch); 130 *ppszString = psz; 131 return VINF_SUCCESS; 132 } 133 return VERR_NO_MEMORY; 125 size_t cch = strlen(pszString); 126 char *pszDst = (char *)RTMemAllocTag(cch + 1, pszTag); 127 if (pszDst) 128 { 129 memcpy(pszDst, pszString, cch); 130 pszDst[cch] = '\0'; 131 *ppszCopy = pszDst; 132 return VINF_SUCCESS; 133 } 134 *ppszCopy = NULL; 135 return VERR_NO_STR_MEMORY; 134 136 } 135 137 RT_EXPORT_SYMBOL(RTStrDupExTag); … … 152 154 } 153 155 RT_EXPORT_SYMBOL(RTStrDupNTag); 156 157 158 RTDECL(int) RTStrDupNExTag(char **ppszCopy, const char *pszString, size_t cchMax, const char *pszTag) 159 { 160 #if defined(__cplusplus) 161 AssertPtr(pszString); 162 #endif 163 char const *pszEnd = RTStrEnd(pszString, cchMax); 164 size_t cch = pszEnd ? (uintptr_t)pszEnd - (uintptr_t)pszString : cchMax; 165 char *pszDst = (char *)RTMemAllocTag(cch + 1, pszTag); 166 if (pszDst) 167 { 168 memcpy(pszDst, pszString, cch); 169 pszDst[cch] = '\0'; 170 *ppszCopy = pszDst; 171 return VINF_SUCCESS; 172 } 173 *ppszCopy = NULL; 174 return VERR_NO_STR_MEMORY; 175 } 176 RT_EXPORT_SYMBOL(RTStrDupNExTag); 154 177 155 178
Note:
See TracChangeset
for help on using the changeset viewer.