Index: src/zone.cc |
diff --git a/src/zone.cc b/src/zone.cc |
index 9dcebba2dc1fc8fee3fd4c5fd363e6f55b3b47c0..461ee73745de5ebcaf8caf295e12e89854d65f86 100644 |
--- a/src/zone.cc |
+++ b/src/zone.cc |
@@ -72,15 +72,14 @@ class Segment { |
size_t size_; |
}; |
- |
-Zone::Zone() |
+Zone::Zone(base::AccountingAllocator* allocator) |
: allocation_size_(0), |
segment_bytes_allocated_(0), |
position_(0), |
limit_(0), |
+ allocator_(allocator), |
segment_head_(nullptr) {} |
- |
Zone::~Zone() { |
DeleteAll(); |
DeleteKeptSegment(); |
@@ -201,7 +200,7 @@ void Zone::DeleteKeptSegment() { |
// Creates a new segment, sets it size, and pushes it to the front |
// of the segment chain. Returns the new segment. |
Segment* Zone::NewSegment(size_t size) { |
- Segment* result = reinterpret_cast<Segment*>(Malloced::New(size)); |
+ Segment* result = reinterpret_cast<Segment*>(allocator_->Allocate(size)); |
segment_bytes_allocated_ += size; |
if (result != nullptr) { |
result->Initialize(segment_head_, size); |
@@ -214,7 +213,7 @@ Segment* Zone::NewSegment(size_t size) { |
// Deletes the given segment. Does not touch the segment chain. |
void Zone::DeleteSegment(Segment* segment, size_t size) { |
segment_bytes_allocated_ -= size; |
- Malloced::Delete(segment); |
+ allocator_->Free(segment, size); |
} |