mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-01-19 08:52:34 +01:00
Fixed destructor to free all items properly
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40116
This commit is contained in:
parent
18bfaa7021
commit
3130242ca8
@ -63,17 +63,11 @@ namespace SourceHook
|
||||
|
||||
~THash()
|
||||
{
|
||||
if (m_Buckets)
|
||||
delete [] m_Buckets;
|
||||
_Clear();
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
if (m_Buckets)
|
||||
delete [] m_Buckets;
|
||||
m_Buckets = NULL;
|
||||
m_numBuckets = 0;
|
||||
m_percentUsed = 0.0f;
|
||||
|
||||
_Clear();
|
||||
_Refactor();
|
||||
}
|
||||
size_t GetBuckets()
|
||||
@ -90,6 +84,21 @@ namespace SourceHook
|
||||
return pNode->val;
|
||||
}
|
||||
private:
|
||||
void _Clear()
|
||||
{
|
||||
for (size_t i=0; i<m_numBuckets; i++)
|
||||
{
|
||||
if (m_Buckets[i])
|
||||
{
|
||||
delete m_Buckets[i];
|
||||
m_Buckets[i] = NULL;
|
||||
}
|
||||
}
|
||||
if (m_Buckets)
|
||||
delete [] m_Buckets;
|
||||
m_Buckets = NULL;
|
||||
m_numBuckets = 0;
|
||||
}
|
||||
THashNode *_FindOrInsert(const K & key)
|
||||
{
|
||||
size_t place = HashFunction(key) % m_numBuckets;
|
||||
|
@ -4,6 +4,7 @@
|
||||
Version="7.10"
|
||||
Name="test"
|
||||
ProjectGUID="{456BBA64-FF14-4292-8443-3BA79E4D84CC}"
|
||||
RootNamespace="test"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
@ -264,6 +265,9 @@
|
||||
<File
|
||||
RelativePath=".\testbail2.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\testlist.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
|
Loading…
x
Reference in New Issue
Block a user