| Index: src/splay-tree.h
|
| diff --git a/src/splay-tree.h b/src/splay-tree.h
|
| index 0cb9ea8405dd0bb7265f6737ff06d24ee7729207..2fcbcb26e3214782253d613e43075b6a49a2ad95 100644
|
| --- a/src/splay-tree.h
|
| +++ b/src/splay-tree.h
|
| @@ -48,7 +48,7 @@ namespace internal {
|
| // store or the zone; see zone.h.
|
|
|
| // Forward defined as
|
| -// template <typename Config, class Allocator = FreeStoreAllocationPolicy>
|
| +// template <typename Config, class Allocator = FreeStoreAllocator>
|
| // class SplayTree;
|
| template <typename Config, class Allocator>
|
| class SplayTree {
|
| @@ -58,13 +58,16 @@ class SplayTree {
|
|
|
| class Locator;
|
|
|
| - SplayTree() : root_(NULL) { }
|
| + explicit SplayTree(const Allocator& allocator = Allocator())
|
| + : allocator_(allocator), root_(NULL) { }
|
| ~SplayTree();
|
|
|
| INLINE(void* operator new(size_t size)) {
|
| - return Allocator::New(static_cast<int>(size));
|
| + return Allocator().New(static_cast<int>(size));
|
| + }
|
| + INLINE(void operator delete(void* p, size_t)) {
|
| + return Allocator().Delete(p);
|
| }
|
| - 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 +115,12 @@ 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, Allocator* allocator)) {
|
| + return allocator->New(static_cast<int>(size));
|
| }
|
| - INLINE(void operator delete(void* p, size_t)) {
|
| - return Allocator::Delete(p);
|
| + static void Delete(Allocator* allocator, Node* node) {
|
| + node->~Node();
|
| + allocator->Delete(node);
|
| }
|
|
|
| Key key() { return key_; }
|
| @@ -124,6 +128,7 @@ class SplayTree {
|
| Node* left() { return left_; }
|
| Node* right() { return right_; }
|
| private:
|
| + void operator delete(void* p, size_t);
|
|
|
| friend class SplayTree;
|
| friend class Locator;
|
| @@ -183,10 +188,11 @@ class SplayTree {
|
|
|
| class NodeDeleter BASE_EMBEDDED {
|
| public:
|
| - NodeDeleter() { }
|
| - void Call(Node* node) { delete node; }
|
| + explicit NodeDeleter(Allocator* allocator) : allocator_(allocator) { }
|
| + void Call(Node* node) { Node::Delete(allocator_, node); }
|
|
|
| private:
|
| + Allocator* allocator_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(NodeDeleter);
|
| };
|
| @@ -194,6 +200,7 @@ class SplayTree {
|
| template <class Callback>
|
| void ForEachNode(Callback* callback);
|
|
|
| + Allocator allocator_;
|
| Node* root_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(SplayTree);
|
|
|