]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
Committing in .
[wxWidgets.git] / src / common / string.cpp
index da23dda0f4862e0c0769879fa8e78c1aac0cb1a5..f37934d939c1aa8b65c26ca4fe76a14df9c4b4a2 100644 (file)
@@ -360,8 +360,13 @@ wxString::wxString(const wchar_t *pwz)
 // allocates memory needed to store a C string of length nLen
 void wxString::AllocBuffer(size_t nLen)
 {
-  wxASSERT( nLen >  0         );    //
-  wxASSERT( nLen <= INT_MAX-1 );    // max size (enough room for 1 extra)
+  // allocating 0 sized buffer doesn't make sense, all empty strings should
+  // reuse g_strEmpty
+  wxASSERT( nLen >  0 );
+
+  // make sure that we don't overflow
+  wxASSERT( nLen < (INT_MAX / sizeof(wxChar)) -
+                   (sizeof(wxStringData) + EXTRA_ALLOC + 1) );
 
   STATISTICS_ADD(Length, nLen);
 
@@ -1071,33 +1076,6 @@ bool wxString::ToDouble(double *val) const
     return !*end && (end != start);
 }
 
-// ---------------------------------------------------------------------------
-// stream-like operators
-// ---------------------------------------------------------------------------
-wxString& wxString::operator<<(int i)
-{
-    wxString res;
-    res.Printf(wxT("%d"), i);
-
-    return (*this) << res;
-}
-
-wxString& wxString::operator<<(float f)
-{
-    wxString res;
-    res.Printf(wxT("%f"), f);
-
-    return (*this) << res;
-}
-
-wxString& wxString::operator<<(double d)
-{
-    wxString res;
-    res.Printf(wxT("%g"), d);
-
-    return (*this) << res;
-}
-
 // ---------------------------------------------------------------------------
 // formatted output
 // ---------------------------------------------------------------------------