Chromium Code Reviews| 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 63d40611a6f6dcef24d2f524ff60ebf1994dfe62..9d30507aeceb2765a531e94e84c68b4fcb672796 100644 |
| --- a/base/trace_event/heap_profiler_allocation_register.cc |
| +++ b/base/trace_event/heap_profiler_allocation_register.cc |
| @@ -81,12 +81,12 @@ AllocationRegister::AllocationRegister(size_t allocation_capacity, |
| AllocationRegister::~AllocationRegister() { |
| } |
| -void AllocationRegister::Insert(const void* address, |
| +bool AllocationRegister::Insert(const void* address, |
|
Primiano Tucci (use gerrit)
2017/03/30 13:32:40
do we need this bool here?
If it's just for the te
awong
2017/03/31 04:28:30
I feel like the API is cleaner to have a bool retu
Primiano Tucci (use gerrit)
2017/03/31 19:05:47
Not strong enough to justify another round on this
|
| size_t size, |
| const AllocationContext& context) { |
| DCHECK(address != nullptr); |
| if (size == 0) { |
| - return; |
| + return false; |
| } |
| AllocationInfo info = { |
| @@ -97,12 +97,15 @@ void AllocationRegister::Insert(const void* address, |
| // Try to insert the allocation. |
| auto index_and_flag = allocations_.Insert(address, info); |
| - if (!index_and_flag.second) { |
| + if (!index_and_flag.second && |
| + index_and_flag.first != AllocationMap::kInvalidKVIndex) { |
| // |address| is already there - overwrite the allocation info. |
| auto& old_info = allocations_.Get(index_and_flag.first).second; |
| RemoveBacktrace(old_info.backtrace_index); |
| old_info = info; |
| } |
| + |
| + return index_and_flag.second; |
| } |
| void AllocationRegister::Remove(const void* address) { |