Fixed bug in Grow function (possibly not allocating enough memory if starting

with empty array).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17128 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Neis
2002-09-11 10:29:28 +00:00
parent b00e9f10c7
commit a1db4ad4a4
2 changed files with 8 additions and 3 deletions

View File

@@ -112,11 +112,14 @@ void name::Grow(size_t nIncrement) \
/* only do it if no more place */ \
if( m_nCount == m_nSize ) { \
if( m_nSize == 0 ) { \
/* was empty, alloc some memory */ \
m_pItems = new T[WX_ARRAY_DEFAULT_INITIAL_SIZE]; \
/* was empty, determine initial size */ \
size_t size = WX_ARRAY_DEFAULT_INITIAL_SIZE; \
if (size < nIncrement) size = nIncrement; \
/* allocate some memory */ \
m_pItems = new T[size]; \
/* only grow if allocation succeeded */ \
if ( m_pItems ) { \
m_nSize = WX_ARRAY_DEFAULT_INITIAL_SIZE; \
m_nSize = size; \
} \
} \
else \

View File

@@ -1762,6 +1762,8 @@ void wxArrayString::Grow(size_t nIncrement)
if ( m_nSize == 0 ) {
// was empty, alloc some memory
m_nSize = ARRAY_DEFAULT_INITIAL_SIZE;
if (m_nSize < nIncrement)
m_nSize = nIncrement;
m_pItems = new wxChar *[m_nSize];
}
else {