From 3130242ca8fc86d62d4f1384fa2253d5642f9dab Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 26 Sep 2005 16:05:07 +0000 Subject: [PATCH] Fixed destructor to free all items properly --HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40116 --- sourcehook/sh_tinyhash.h | 25 +++++++++++++++++-------- sourcehook/test/test.vcproj | 4 ++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/sourcehook/sh_tinyhash.h b/sourcehook/sh_tinyhash.h index 52b6e85..a7ddddd 100644 --- a/sourcehook/sh_tinyhash.h +++ b/sourcehook/sh_tinyhash.h @@ -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 + +