fixed a bug in the index-based linked list template which caused head or tail removals (but not both) to result in a corrupt link chain
fixed a bug in the index-based linked list template which caused head or tail removals (but not both) to result in a corrupt link chain
additionally, fixed a bug where the list size was not maintained properly
1.1 --- a/core/sm_fastlink.h Wed May 23 23:42:04 2007 +0000
1.2 +++ b/core/sm_fastlink.h Thu May 24 02:25:18 2007 +0000
1.3 @@ -16,6 +16,8 @@
1.4 #ifndef _INCLUDE_SOURCEMOD_FASTLINK_H_
1.5 #define _INCLUDE_SOURCEMOD_FASTLINK_H_
1.6
1.7 +#include <assert.h>
1.8 +
1.9 template <typename T>
1.10 class FastLink
1.11 {
1.12 @@ -158,13 +160,13 @@
1.13 else if (index == m_FirstLink)
1.14 {
1.15 m_FirstLink = m_Nodes[index].next;
1.16 - m_Nodes[index].prev = 0;
1.17 + m_Nodes[m_FirstLink].prev = 0;
1.18 }
1.19 /* We're the TAIL */
1.20 else if (index == m_LastLink)
1.21 {
1.22 m_LastLink = m_Nodes[index].prev;
1.23 - m_Nodes[index].next = 0;
1.24 + m_Nodes[m_LastLink].next = 0;
1.25 }
1.26 /* We're in the middle! */
1.27 else
1.28 @@ -178,6 +180,8 @@
1.29 /* Add us to the free list */
1.30 m_Nodes[++m_FreeNodes].freeNode = index;
1.31
1.32 + m_Size--;
1.33 +
1.34 return iter;
1.35 }
1.36 private: