X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9257d0b705e4d331dfea6481cf577dbb350cd597..706bb5f973ccb44a924ee1f9aa79c7ee34eb2556:/src/common/list.cpp diff --git a/src/common/list.cpp b/src/common/list.cpp index a98385159d..85448991d2 100644 --- a/src/common/list.cpp +++ b/src/common/list.cpp @@ -37,17 +37,6 @@ #include "wx/utils.h" // for copystring() (beurk...) #endif -// Sun CC compatibility (interference with xview/pkg.h, apparently...) -// But XView is no longer supported. -/* -#if defined (SUN_CC) || defined(__SUNCC__) && defined(__XVIEW__) - #undef va_start - #undef va_end - #undef va_arg - #undef va_list -#endif -*/ - // ============================================================================= // implementation // ============================================================================= @@ -56,6 +45,8 @@ // wxListKey // ----------------------------------------------------------------------------- +wxListKey wxDefaultListKey; + bool wxListKey::operator==(wxListKeyValue value) const { switch ( m_keyType ) @@ -118,13 +109,18 @@ wxNodeBase::~wxNodeBase() // compatibility with old code if ( m_list != NULL ) { + if ( m_list->m_keyType == wxKEY_STRING ) + { + free(m_key.string); + } + m_list->DetachNode(this); } } int wxNodeBase::IndexOf() const { - wxCHECK_MSG( m_list, NOT_FOUND, "node doesn't belong to a list in IndexOf"); + wxCHECK_MSG( m_list, wxNOT_FOUND, "node doesn't belong to a list in IndexOf"); // It would be more efficient to implement IndexOf() completely inside // wxListBase (only traverse the list once), but this is probably a more @@ -145,7 +141,7 @@ int wxNodeBase::IndexOf() const // wxListBase // ----------------------------------------------------------------------------- -void wxListBase::Init(wxKeyType keyType = wxKEY_NONE) +void wxListBase::Init(wxKeyType keyType) { m_nodeFirst = m_nodeLast = (wxNodeBase *) NULL; @@ -330,7 +326,7 @@ int wxListBase::IndexOf(void *object) const { wxNodeBase *node = Find( object ); - return node ? node->IndexOf() : NOT_FOUND; + return node ? node->IndexOf() : wxNOT_FOUND; } void wxListBase::DoDeleteNode(wxNodeBase *node) @@ -346,6 +342,8 @@ void wxListBase::DoDeleteNode(wxNodeBase *node) node->DeleteData(); } + // so that the node knows that it's being deleted by the list + node->m_list = NULL; delete node; } @@ -620,9 +618,10 @@ void wxStringList::Sort() { size_t N = GetCount(); char **array = new char *[N]; + wxStringListNode *node; size_t i = 0; - for ( wxStringListNode *node = GetFirst(); node; node = node->GetNext() ) + for ( node = GetFirst(); node; node = node->GetNext() ) { array[i++] = node->GetData(); }