From ca3c8eb6b7d079d2d8f0e971667a51a9b2c5ee87 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 24 May 2007 02:25:18 +0000 Subject: [PATCH] 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 --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40860 --- core/sm_fastlink.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/sm_fastlink.h b/core/sm_fastlink.h index 3de9526a..a35a0c6b 100644 --- a/core/sm_fastlink.h +++ b/core/sm_fastlink.h @@ -16,6 +16,8 @@ #ifndef _INCLUDE_SOURCEMOD_FASTLINK_H_ #define _INCLUDE_SOURCEMOD_FASTLINK_H_ +#include + template class FastLink { @@ -158,13 +160,13 @@ public: else if (index == m_FirstLink) { m_FirstLink = m_Nodes[index].next; - m_Nodes[index].prev = 0; + m_Nodes[m_FirstLink].prev = 0; } /* We're the TAIL */ else if (index == m_LastLink) { m_LastLink = m_Nodes[index].prev; - m_Nodes[index].next = 0; + m_Nodes[m_LastLink].next = 0; } /* We're in the middle! */ else @@ -178,6 +180,8 @@ public: /* Add us to the free list */ m_Nodes[++m_FreeNodes].freeNode = index; + m_Size--; + return iter; } private: