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
This commit is contained in:
parent
df9b23948b
commit
ca3c8eb6b7
@ -16,6 +16,8 @@
|
||||
#ifndef _INCLUDE_SOURCEMOD_FASTLINK_H_
|
||||
#define _INCLUDE_SOURCEMOD_FASTLINK_H_
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
template <typename T>
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user