Changeset 67674 in vbox for trunk/src/VBox/Runtime/common/string/ministring.cpp
- Timestamp:
- Jun 28, 2017 10:26:10 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/ministring.cpp
r67673 r67674 104 104 RTCString &RTCString::append(const RTCString &that) 105 105 { 106 size_t cchThat = that.length(); 107 if (cchThat) 106 Assert(&that != this); 107 return appendWorker(that.c_str(), that.length()); 108 } 109 110 RTCString &RTCString::append(const char *pszThat) 111 { 112 return appendWorker(pszThat, strlen(pszThat)); 113 } 114 115 RTCString &RTCString::append(const RTCString &rThat, size_t offStart, size_t cchMax /*= RTSTR_MAX*/) 116 { 117 if (offStart < rThat.length()) 118 { 119 size_t cchLeft = rThat.length() - offStart; 120 return appendWorker(rThat.c_str() + offStart, RT_MIN(cchLeft, cchMax)); 121 } 122 return *this; 123 } 124 125 RTCString &RTCString::append(const char *pszThat, size_t cchMax) 126 { 127 return appendWorker(pszThat, RTStrNLen(pszThat, cchMax)); 128 } 129 130 RTCString &RTCString::appendWorker(const char *pszSrc, size_t cchSrc) 131 { 132 if (cchSrc) 108 133 { 109 134 size_t cchThis = length(); 110 size_t cchBoth = cchThis + cch That;135 size_t cchBoth = cchThis + cchSrc; 111 136 112 137 if (cchBoth >= m_cbAllocated) … … 119 144 } 120 145 121 memcpy(m_psz + cchThis, that.m_psz, cchThat); 122 m_psz[cchBoth] = '\0'; 123 m_cch = cchBoth; 124 } 125 return *this; 126 } 127 128 RTCString &RTCString::append(const char *pszThat) 129 { 130 size_t cchThat = strlen(pszThat); 131 if (cchThat) 132 { 133 size_t cchThis = length(); 134 size_t cchBoth = cchThis + cchThat; 135 136 if (cchBoth >= m_cbAllocated) 137 { 138 reserve(RT_ALIGN_Z(cchBoth + 1, IPRT_MINISTRING_APPEND_ALIGNMENT)); 139 // calls realloc(cchBoth + 1) and sets m_cbAllocated; may throw bad_alloc. 140 #ifndef RT_EXCEPTIONS_ENABLED 141 AssertRelease(capacity() > cchBoth); 142 #endif 143 } 144 145 memcpy(&m_psz[cchThis], pszThat, cchThat); 146 memcpy(&m_psz[cchThis], pszSrc, cchSrc); 146 147 m_psz[cchBoth] = '\0'; 147 148 m_cch = cchBoth;
Note:
See TracChangeset
for help on using the changeset viewer.