]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dynarray.cpp
Added support for delayed deactivation of windows (for MDI)
[wxWidgets.git] / src / common / dynarray.cpp
index 72284fcb73ca57ffe1520af6ee887457d16af0a5..2b185f156f4f91f3ff4230645073df0c4f199e37 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     12.09.97
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -221,7 +221,11 @@ void name::Shrink()                                                         \
         memcpy(pNew, m_pItems, m_nCount*sizeof(T));                         \
         delete [] m_pItems;                                                 \
         m_pItems = pNew;                                                    \
+                                                                            \
+        /* update the size of the new block */                              \
+        m_nSize = m_nCount;                                                 \
     }                                                                       \
+    /* else: don't do anything, better keep old memory block! */            \
   }                                                                         \
 }                                                                           \
                                                                             \
@@ -279,7 +283,10 @@ int name::Index(T lItem, CMPFUNC fnCompare) const                           \
 {                                                                           \
     size_t n = IndexForInsert(lItem, fnCompare);                            \
                                                                             \
-    return n < m_nCount && m_pItems[n] == lItem ? (int)n : wxNOT_FOUND;     \
+    return (n >= m_nCount ||                                                \
+           (*fnCompare)((const void *)(long)lItem,                          \
+                        ((const void *)(long)m_pItems[n]))) ? wxNOT_FOUND   \
+                                                            : (int)n;       \
 }                                                                           \
                                                                             \
 /* add item at the end */                                                   \