summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-08-07 13:33:55 +0000
committersmatz <smatz@openttd.org>2009-08-07 13:33:55 +0000
commit135f80f95bc9a3756bd453b93006653bf9eb82b5 (patch)
tree355dae630c882ddd8b5b532b7844abc1615f3e24 /src/misc
parentba4fd897b823fa4dc36ad3fbf0db36b94b95628b (diff)
downloadopenttd-135f80f95bc9a3756bd453b93006653bf9eb82b5.tar.xz
(svn r17101) -Revert [FS#3065](r16546): large table on stack caused stack overflow on some architectures
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/hashtable.hpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/misc/hashtable.hpp b/src/misc/hashtable.hpp
index 2e524e632..f7b5a84d8 100644
--- a/src/misc/hashtable.hpp
+++ b/src/misc/hashtable.hpp
@@ -133,16 +133,19 @@ protected:
* Titem contains pointer to the next item - GetHashNext(), SetHashNext() */
typedef CHashTableSlotT<Titem_> Slot;
- Slot m_slots[Tcapacity]; ///< here we store our data (array of blobs)
- int m_num_items; ///< item counter
+ Slot *m_slots; // here we store our data (array of blobs)
+ int m_num_items; // item counter
public:
/* default constructor */
- FORCEINLINE CHashTableT() :
- m_num_items(0)
- { }
+ FORCEINLINE CHashTableT()
+ {
+ /* construct all slots */
+ m_slots = new Slot[Tcapacity];
+ m_num_items = 0;
+ }
- FORCEINLINE ~CHashTableT() { }
+ ~CHashTableT() {delete [] m_slots; m_num_items = 0; m_slots = NULL;}
protected:
/** static helper - return hash for the given key modulo number of slots */
@@ -165,10 +168,7 @@ public:
FORCEINLINE int Count() const {return m_num_items;}
/** simple clear - forget all items - used by CSegmentCostCacheT.Flush() */
- FORCEINLINE void Clear()
- {
- for (size_t i = 0; i < lengthof(m_slots); i++) m_slots[i].Clear();
- }
+ FORCEINLINE void Clear() const {for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();}
/** const item search */
const Titem_ *Find(const Tkey& key) const