@@ -16,13 +16,6 @@ class FixedMAP
1616 K key;
1717 T val;
1818 TNode *left, *right;
19-
20- TNode () : key(), val(), left(nullptr ), right(nullptr ) {}
21-
22- static void *operator new (size_t size) { return allocator::alloc (size); }
23- static void *operator new [](size_t size) { return allocator::alloc (size); }
24- static void operator delete (void *block) { allocator::dealloc (block); }
25- static void operator delete[] (void *block) { allocator::dealloc (block); }
2619 };
2720 typedef void __fastcall callback (TNode*);
2821 typedef bool __fastcall callback_cmp (TNode& N1, TNode& N2);
@@ -32,14 +25,15 @@ class FixedMAP
3225 u32 pool;
3326 u32 limit;
3427
35- IC u32 Size (u32 Count) { return Count * sizeof (TNode); }
3628 void Realloc ()
3729 {
3830 u32 newLimit = limit + SG_REALLOC_ADVANCE;
3931 VERIFY (newLimit % SG_REALLOC_ADVANCE == 0 );
40- TNode* newNodes = new TNode[ newLimit] ;
32+ TNode* newNodes = ( TNode*) allocator::alloc ( sizeof (TNode) * newLimit) ;
4133 VERIFY (newNodes);
4234
35+ for (TNode* cur = newNodes + limit; cur != newNodes + newLimit; cur++)
36+ new (cur) TNode ();
4337 if (limit)
4438 std::copy (nodes, nodes + limit, newNodes);
4539
@@ -61,7 +55,7 @@ class FixedMAP
6155 }
6256 }
6357 if (nodes)
64- delete[] nodes;
58+ allocator::dealloc ( nodes) ;
6559
6660 nodes = newNodes;
6761 limit = newLimit;
@@ -145,7 +139,11 @@ class FixedMAP
145139 void destroy ()
146140 {
147141 if (nodes)
148- delete[] nodes;
142+ {
143+ for (TNode* cur = begin (); cur != end (); cur++)
144+ cur->~TNode ();
145+ allocator::dealloc (nodes);
146+ }
149147 nodes = 0 ;
150148 pool = 0 ;
151149 limit = 0 ;
0 commit comments