| Index: base/trace_event/heap_profiler_allocation_register.cc
|
| diff --git a/base/trace_event/heap_profiler_allocation_register.cc b/base/trace_event/heap_profiler_allocation_register.cc
|
| index 37647eefbbb1246bea852f86adfe6843903801ee..825a0d0b9ad1d4e5d247167858701758e45f214a 100644
|
| --- a/base/trace_event/heap_profiler_allocation_register.cc
|
| +++ b/base/trace_event/heap_profiler_allocation_register.cc
|
| @@ -10,10 +10,14 @@ namespace base {
|
| namespace trace_event {
|
|
|
| AllocationRegister::AllocationRegister()
|
| - // Reserve enough address space to store |kNumCells| entries if necessary,
|
| + : AllocationRegister(kNumBuckets * kNumCellsPerBucket) {}
|
| +
|
| +AllocationRegister::AllocationRegister(uint32_t num_cells)
|
| + // Reserve enough address space to store |num_cells_| entries if necessary,
|
| // with a guard page after it to crash the program when attempting to store
|
| // more entries.
|
| - : cells_(static_cast<Cell*>(AllocateVirtualMemory(kNumCells *
|
| + : num_cells_(num_cells),
|
| + cells_(static_cast<Cell*>(AllocateVirtualMemory(num_cells_ *
|
| sizeof(Cell)))),
|
| buckets_(static_cast<CellIndex*>(
|
| AllocateVirtualMemory(kNumBuckets * sizeof(CellIndex)))),
|
| @@ -25,7 +29,7 @@ AllocationRegister::AllocationRegister()
|
|
|
| AllocationRegister::~AllocationRegister() {
|
| FreeVirtualMemory(buckets_, kNumBuckets * sizeof(CellIndex));
|
| - FreeVirtualMemory(cells_, kNumCells * sizeof(Cell));
|
| + FreeVirtualMemory(cells_, num_cells_ * sizeof(Cell));
|
| }
|
|
|
| void AllocationRegister::Insert(void* address,
|
| @@ -144,7 +148,7 @@ AllocationRegister::CellIndex AllocationRegister::GetFreeCell() {
|
| // the simplest solution is to just allocate a humongous chunk of address
|
| // space.
|
|
|
| - DCHECK_LT(next_unused_cell_, kNumCells + 1);
|
| + DCHECK_LT(next_unused_cell_, num_cells_ + 1);
|
|
|
| return idx;
|
| }
|
|
|