X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/31444b6aa411253e0523edfa8e7e361d408c2adc..3077d1230554bda900da26302fe3b915e7b3de20:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index 2401cc6388..20c11c569a 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -968,6 +968,7 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength) wxCharBuffer inBuf((const char *)NULL); if (nLength != npos) { + wxASSERT( psz != NULL ); wxCharBuffer tmp(nLength); memcpy(tmp.data(), psz, nLength); tmp.data()[nLength] = '\0'; @@ -1025,6 +1026,7 @@ wxString::wxString(const wchar_t *pwz, wxMBConv& conv, size_t nLength) wxWCharBuffer inBuf((const wchar_t *)NULL); if (nLength != npos) { + wxASSERT( pwz != NULL ); wxWCharBuffer tmp(nLength); memcpy(tmp.data(), pwz, nLength * sizeof(wchar_t)); tmp.data()[nLength] = '\0'; @@ -2221,6 +2223,30 @@ void wxArrayString::Insert(const wxString& str, size_t nIndex, size_t nInsert) m_nCount += nInsert; } +// range insert (STL 23.2.4.3) +void +wxArrayString::insert(iterator it, const_iterator first, const_iterator last) +{ + const int idx = it - begin(); + + // grow it once + Grow(last - first); + + // reset "it" since it can change inside Grow() + it = begin() + idx; + + while ( first != last ) + { + it = insert(it, *first); + + // insert returns an iterator to the last element inserted but we need + // insert the next after this one, that is before the next one + ++it; + + ++first; + } +} + // expand the array void wxArrayString::SetCount(size_t count) {