]> git.saurik.com Git - wxWidgets.git/commitdiff
wxArrayString::Alloc() shouldn't clear the array contents
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 8 Nov 2006 18:52:43 +0000 (18:52 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 8 Nov 2006 18:52:43 +0000 (18:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43203 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/common/string.cpp

index a799e31985cf5dea7e6b1ecb1de576197f25a9cc..0520684946caaab888a7376ea032fa291d79612f 100644 (file)
@@ -69,12 +69,19 @@ Deprecated methods since 2.6.x and their replacements
 
 
 
-Major new features in 2.7 release
+Major new features in 2.8 release
 ---------------------------------
 
 - New AUI library supporting docking windows and much more.
 
 
+2.8.0
+-----
+
+All:
+
+- wxArrayString::Alloc() now works as reserve() and doesn't clear array contents
+
 2.7.2
 -----
 
index 4551c669318d178426b6ff5b4f0629ad125781f6..8a722a4f4c264727ac131d364b98ff2245b64b52 100644 (file)
@@ -2191,13 +2191,16 @@ void wxArrayString::Alloc(size_t nSize)
 {
   // only if old buffer was not big enough
   if ( nSize > m_nSize ) {
-    Free();
-    wxDELETEA(m_pItems);
-    m_pItems = new wxChar *[nSize];
+    wxChar **pNew = new wxChar *[nSize];
+    if ( !pNew )
+        return;
+
+    memcpy(pNew, m_pItems, m_nCount*sizeof(wxChar *));
+    delete [] m_pItems;
+
+    m_pItems = pNew;
     m_nSize  = nSize;
   }
-
-  m_nCount = 0;
 }
 
 // minimizes the memory usage by freeing unused memory