diff options
Diffstat (limited to 'src/3rdparty/v8/src/splay-tree.h')
-rw-r--r-- | src/3rdparty/v8/src/splay-tree.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/3rdparty/v8/src/splay-tree.h b/src/3rdparty/v8/src/splay-tree.h index 72231e4..8844d8a 100644 --- a/src/3rdparty/v8/src/splay-tree.h +++ b/src/3rdparty/v8/src/splay-tree.h @@ -50,7 +50,7 @@ namespace internal { // Forward defined as // template <typename Config, class Allocator = FreeStoreAllocationPolicy> // class SplayTree; -template <typename Config, class Allocator> +template <typename Config, class AllocationPolicy> class SplayTree { public: typedef typename Config::Key Key; @@ -58,13 +58,21 @@ class SplayTree { class Locator; - SplayTree() : root_(NULL) { } + SplayTree(AllocationPolicy allocator = AllocationPolicy()) + : root_(NULL), allocator_(allocator) { } ~SplayTree(); - INLINE(void* operator new(size_t size)) { - return Allocator::New(static_cast<int>(size)); + INLINE(void* operator new(size_t size, + AllocationPolicy allocator = AllocationPolicy())) { + return allocator.New(static_cast<int>(size)); + } + INLINE(void operator delete(void* p)) { + AllocationPolicy::Delete(p); + } + // Please the MSVC compiler. We should never have to execute this. + INLINE(void operator delete(void* p, AllocationPolicy policy)) { + UNREACHABLE(); } - INLINE(void operator delete(void* p, size_t)) { return Allocator::Delete(p); } // Inserts the given key in this tree with the given value. Returns // true if a node was inserted, otherwise false. If found the locator @@ -112,11 +120,16 @@ class SplayTree { left_(NULL), right_(NULL) { } - INLINE(void* operator new(size_t size)) { - return Allocator::New(static_cast<int>(size)); + INLINE(void* operator new(size_t size, AllocationPolicy allocator)) { + return allocator.New(static_cast<int>(size)); + } + INLINE(void operator delete(void* p)) { + return AllocationPolicy::Delete(p); } - INLINE(void operator delete(void* p, size_t)) { - return Allocator::Delete(p); + // Please the MSVC compiler. We should never have to execute + // this. + INLINE(void operator delete(void* p, AllocationPolicy allocator)) { + UNREACHABLE(); } Key key() { return key_; } @@ -184,7 +197,7 @@ class SplayTree { class NodeDeleter BASE_EMBEDDED { public: NodeDeleter() { } - void Call(Node* node) { delete node; } + void Call(Node* node) { AllocationPolicy::Delete(node); } private: DISALLOW_COPY_AND_ASSIGN(NodeDeleter); @@ -194,6 +207,7 @@ class SplayTree { void ForEachNode(Callback* callback); Node* root_; + AllocationPolicy allocator_; DISALLOW_COPY_AND_ASSIGN(SplayTree); }; |