fixed a serious corruption bug in fastlink causing menus to corrupt memory after a while
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401137
This commit is contained in:
parent
5fab1ce2c5
commit
0069612c95
@ -194,6 +194,16 @@ void BaseMenuStyle::ProcessWatchList()
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined MENU_DEBUG
|
||||
g_Logger.LogMessage("BaseMenuStyle::ProcessWatchList(%d,%d,%d,%d,%d,%p)",
|
||||
m_WatchList.m_Size,
|
||||
m_WatchList.m_FirstLink,
|
||||
m_WatchList.m_FreeNodes,
|
||||
m_WatchList.m_LastLink,
|
||||
m_WatchList.m_MaxSize,
|
||||
m_WatchList.m_Nodes);
|
||||
#endif
|
||||
|
||||
unsigned int total = 0;
|
||||
for (FastLink<int>::iterator iter=m_WatchList.begin(); iter!=m_WatchList.end(); ++iter)
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
T obj;
|
||||
};
|
||||
public:
|
||||
FastLink(unsigned int maxsize) : m_Size(0), m_FirstLink(0), m_FreeNodes(0), m_LastLink(0)
|
||||
FastLink(unsigned int maxsize) : m_Size(0), m_FirstLink(0), m_FreeNodes(0), m_LastLink(0), m_UsableIndex(0)
|
||||
{
|
||||
m_MaxSize = maxsize;
|
||||
m_Nodes = new FastLinkNode[m_MaxSize+1];
|
||||
@ -70,11 +70,12 @@ private:
|
||||
{
|
||||
return m_Nodes[m_FreeNodes--].freeNode;
|
||||
} else {
|
||||
if (m_LastLink >= m_MaxSize)
|
||||
if (m_UsableIndex >= m_MaxSize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return m_LastLink + 1;
|
||||
m_UsableIndex++;
|
||||
return m_UsableIndex;
|
||||
}
|
||||
}
|
||||
public:
|
||||
@ -184,12 +185,17 @@ public:
|
||||
|
||||
return iter;
|
||||
}
|
||||
#if defined MENU_DEBUG
|
||||
public:
|
||||
#else
|
||||
private:
|
||||
#endif
|
||||
size_t m_Size;
|
||||
unsigned int m_FirstLink;
|
||||
unsigned int m_FreeNodes;
|
||||
unsigned int m_LastLink;
|
||||
unsigned int m_MaxSize;
|
||||
unsigned int m_UsableIndex;
|
||||
FastLinkNode *m_Nodes;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user