]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
use C compiler for tests again, it's useless to use the C++ one for AC_CHECK_FUNCS...
[wxWidgets.git] / src / common / string.cpp
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