Changeset 40798 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Apr 6, 2012 4:44:13 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 77309
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/stringalloc.cpp
r34032 r40798 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 62 62 return VERR_NO_STR_MEMORY; 63 63 } 64 RT_EXPORT_SYMBOL(RTStrAlloc Tag);64 RT_EXPORT_SYMBOL(RTStrAllocExTag); 65 65 66 66 … … 104 104 RTDECL(char *) RTStrDupTag(const char *pszString, const char *pszTag) 105 105 { 106 #if defined(__cplusplus) 106 107 AssertPtr(pszString); 108 #endif 107 109 size_t cch = strlen(pszString) + 1; 108 110 char *psz = (char *)RTMemAllocTag(cch, pszTag); … … 116 118 RTDECL(int) RTStrDupExTag(char **ppszString, const char *pszString, const char *pszTag) 117 119 { 120 #if defined(__cplusplus) 118 121 AssertPtr(ppszString); 119 122 AssertPtr(pszString); 123 #endif 120 124 121 125 size_t cch = strlen(pszString) + 1; … … 134 138 RTDECL(char *) RTStrDupNTag(const char *pszString, size_t cchMax, const char *pszTag) 135 139 { 140 #if defined(__cplusplus) 136 141 AssertPtr(pszString); 142 #endif 137 143 char const *pszEnd = RTStrEnd(pszString, cchMax); 138 144 size_t cch = pszEnd ? (uintptr_t)pszEnd - (uintptr_t)pszString : cchMax; … … 158 164 RTDECL(int) RTStrAAppendNTag(char **ppsz, const char *pszAppend, size_t cchAppend, const char *pszTag) 159 165 { 166 size_t cchOrg; 167 char *pszNew; 168 160 169 if (!cchAppend) 161 170 return VINF_SUCCESS; … … 165 174 Assert(cchAppend == RTStrNLen(pszAppend, cchAppend)); 166 175 167 size_t constcchOrg = *ppsz ? strlen(*ppsz) : 0;168 char *pszNew = (char *)RTMemReallocTag(*ppsz, cchOrg + cchAppend + 1, pszTag);176 cchOrg = *ppsz ? strlen(*ppsz) : 0; 177 pszNew = (char *)RTMemReallocTag(*ppsz, cchOrg + cchAppend + 1, pszTag); 169 178 if (!pszNew) 170 179 return VERR_NO_STR_MEMORY; … … 247 256 RTDECL(int) RTStrATruncateTag(char **ppsz, size_t cchNew, const char *pszTag) 248 257 { 258 char *pszNew; 249 259 char *pszOld = *ppsz; 250 260 if (!cchNew) … … 253 263 { 254 264 *pszOld = '\0'; 255 char *pszNew = (char *)RTMemReallocTag(pszOld, 1, pszTag);265 pszNew = (char *)RTMemReallocTag(pszOld, 1, pszTag); 256 266 if (pszNew) 257 267 *ppsz = pszNew; … … 260 270 else 261 271 { 272 char *pszZero; 262 273 AssertPtrReturn(pszOld, VERR_OUT_OF_RANGE); 263 274 AssertReturn(cchNew < ~(size_t)64, VERR_OUT_OF_RANGE); 264 char *pszZero = RTStrEnd(pszOld, cchNew + 63);275 pszZero = RTStrEnd(pszOld, cchNew + 63); 265 276 AssertReturn(!pszZero || (size_t)(pszZero - pszOld) >= cchNew, VERR_OUT_OF_RANGE); 266 277 pszOld[cchNew] = '\0'; 267 278 if (!pszZero) 268 279 { 269 char *pszNew = (char *)RTMemReallocTag(pszOld, cchNew + 1, pszTag);280 pszNew = (char *)RTMemReallocTag(pszOld, cchNew + 1, pszTag); 270 281 if (pszNew) 271 282 *ppsz = pszNew;
Note:
See TracChangeset
for help on using the changeset viewer.