]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
removed static methods from wxAppTraitsBase, this doesn't work well in non-monolithic...
[wxWidgets.git] / src / common / string.cpp
index 9d16b5302a1264d14cf355d9a7f37545f37408f8..25e4aa3de314525ee7714ff9d52e1e7b0a742dd2 100644 (file)
@@ -79,7 +79,7 @@ static const struct
 } g_strEmpty = { {-1, 0, 0}, wxT('\0') };
 
 // empty C style string: points to 'string data' byte of g_strEmpty
-extern const wxChar WXDLLEXPORT *wxEmptyString = &g_strEmpty.dummy;
+extern const wxChar WXDLLIMPEXP_BASE *wxEmptyString = &g_strEmpty.dummy;
 
 // ----------------------------------------------------------------------------
 // global functions
@@ -160,6 +160,18 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxString& str)
   #define STATISTICS_ADD(av, val)
 #endif // WXSTRING_STATISTICS
 
+// ===========================================================================
+// wxStringData class deallocation
+// ===========================================================================
+
+#if defined(__VISUALC__) && defined(_MT) && !defined(_DLL)
+#  pragma message (__FILE__ ": building with Multithreaded non DLL runtime has a performance impact on wxString!")
+void wxStringData::Free()
+{
+    free(this);
+}
+#endif
+
 // ===========================================================================
 // wxString class core
 // ===========================================================================
@@ -255,6 +267,7 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength)
         if ( conv.MB2WC(m_pchData, psz, nLen + 1) != (size_t)-1 )
         {
             // initialized ok
+            m_pchData[nLen] = 0;
             return;
         }
         //else: the conversion failed -- leave the string empty (what else?)
@@ -608,7 +621,7 @@ wxString& wxString::operator=(const wchar_t *pwz)
 // ---------------------------------------------------------------------------
 
 // add something to this string
-bool wxString::ConcatSelf(int nSrcLen, const wxChar *pszSrcData)
+bool wxString::ConcatSelf(size_t nSrcLen, const wxChar *pszSrcData)
 {
   STATISTICS_ADD(SummandLength, nSrcLen);
 
@@ -761,7 +774,7 @@ wxString wxString::FromAscii(const char ascii)
 
     wxString res;
     res += (wchar_t)(unsigned char) ascii;
-    
+
     return res;
 }
 
@@ -945,8 +958,13 @@ wxString wxString::AfterFirst(wxChar ch) const
 }
 
 // replace first (or all) occurences of some substring with another one
-size_t wxString::Replace(const wxChar *szOld, const wxChar *szNew, bool bReplaceAll)
+size_t
+wxString::Replace(const wxChar *szOld, const wxChar *szNew, bool bReplaceAll)
 {
+    // if we tried to replace an empty string we'd enter an infinite loop below
+    wxCHECK_MSG( szOld && *szOld && szNew, 0,
+                 _T("wxString::Replace(): invalid parameter") );
+
   size_t uiCount = 0;   // count of replacements made
 
   size_t uiOldLen = wxStrlen(szOld);