aboutsummaryrefslogtreecommitdiff
path: root/common/hashmap.h
diff options
context:
space:
mode:
authorMax Horn2008-10-12 22:05:26 +0000
committerMax Horn2008-10-12 22:05:26 +0000
commit95474b048aa742f500f276f782e9998eccfce8d9 (patch)
treed1724aeabc9af30742c64a2cb85e27970bfd648a /common/hashmap.h
parent24dea3aff2e635f19695ac680a33bb6738bbad97 (diff)
downloadscummvm-rg350-95474b048aa742f500f276f782e9998eccfce8d9.tar.gz
scummvm-rg350-95474b048aa742f500f276f782e9998eccfce8d9.tar.bz2
scummvm-rg350-95474b048aa742f500f276f782e9998eccfce8d9.zip
COMMON: Added a new ObjectPool class, with matching operator new/delete overloads
svn-id: r34785
Diffstat (limited to 'common/hashmap.h')
-rw-r--r--common/hashmap.h27
1 files changed, 3 insertions, 24 deletions
diff --git a/common/hashmap.h b/common/hashmap.h
index 81f5ee84b4..bbc227b3ae 100644
--- a/common/hashmap.h
+++ b/common/hashmap.h
@@ -37,15 +37,6 @@
#define USE_HASHMAP_MEMORY_POOL
#ifdef USE_HASHMAP_MEMORY_POOL
#include "common/memorypool.h"
-// FIXME: we sadly can't assume standard C++ to be present
-// on every system we support, so we should get rid of this.
-// The solution should be to write a simple placement new
-// on our own.
-
-// Symbian does not have <new> but the new operator
-#if !defined(__SYMBIAN32__)
-#include <new>
-#endif
#endif
namespace Common {
@@ -100,27 +91,15 @@ public:
};
-#ifdef USE_HASHMAP_MEMORY_POOL
- FixedSizeMemoryPool<sizeof(Node), HASHMAP_MEMORYPOOL_SIZE> _nodePool;
+ ObjectPool<Node, HASHMAP_MEMORYPOOL_SIZE> _nodePool;
Node *allocNode(const Key &key) {
- void* mem = _nodePool.malloc();
- return new (mem) Node(key);
+ return new (_nodePool) Node(key);
}
void freeNode(Node *node) {
- node->~Node();
- _nodePool.free(node);
+ _nodePool.deleteChunk(node);
}
-#else
- Node* allocNode(const Key &key) {
- return new Node(key);
- }
-
- void freeNode(Node *node) {
- delete node;
- }
-#endif
Node **_storage; // hashtable of size arrsize.
uint _mask; /**< Capacity of the HashMap minus one; must be a power of two of minus one */