OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "leak_detector_impl.h" | 5 #include "leak_detector_impl.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 size_t IndexToSize(size_t index) { | 55 size_t IndexToSize(size_t index) { |
56 return sizeof(uint32_t) * index; | 56 return sizeof(uint32_t) * index; |
57 } | 57 } |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 LeakDetectorImpl::LeakReport::LeakReport() : alloc_size_bytes_(0) {} | 61 LeakDetectorImpl::LeakReport::LeakReport() : alloc_size_bytes_(0) {} |
62 | 62 |
| 63 LeakDetectorImpl::LeakReport::LeakReport(const LeakReport& other) = default; |
| 64 |
63 LeakDetectorImpl::LeakReport::~LeakReport() {} | 65 LeakDetectorImpl::LeakReport::~LeakReport() {} |
64 | 66 |
65 bool LeakDetectorImpl::LeakReport::operator<(const LeakReport& other) const { | 67 bool LeakDetectorImpl::LeakReport::operator<(const LeakReport& other) const { |
66 if (alloc_size_bytes_ != other.alloc_size_bytes_) | 68 if (alloc_size_bytes_ != other.alloc_size_bytes_) |
67 return alloc_size_bytes_ < other.alloc_size_bytes_; | 69 return alloc_size_bytes_ < other.alloc_size_bytes_; |
68 for (size_t i = 0; i < call_stack_.size() && i < other.call_stack_.size(); | 70 for (size_t i = 0; i < call_stack_.size() && i < other.call_stack_.size(); |
69 ++i) { | 71 ++i) { |
70 if (call_stack_[i] != other.call_stack_[i]) | 72 if (call_stack_[i] != other.call_stack_[i]) |
71 return call_stack_[i] < other.call_stack_[i]; | 73 return call_stack_[i] < other.call_stack_[i]; |
72 } | 74 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 232 |
231 uintptr_t LeakDetectorImpl::GetOffset(const void* ptr) const { | 233 uintptr_t LeakDetectorImpl::GetOffset(const void* ptr) const { |
232 uintptr_t ptr_value = reinterpret_cast<uintptr_t>(ptr); | 234 uintptr_t ptr_value = reinterpret_cast<uintptr_t>(ptr); |
233 if (ptr_value >= mapping_addr_ && ptr_value < mapping_addr_ + mapping_size_) | 235 if (ptr_value >= mapping_addr_ && ptr_value < mapping_addr_ + mapping_size_) |
234 return ptr_value - mapping_addr_; | 236 return ptr_value - mapping_addr_; |
235 return ptr_value; | 237 return ptr_value; |
236 } | 238 } |
237 | 239 |
238 } // namespace leak_detector | 240 } // namespace leak_detector |
239 } // namespace metrics | 241 } // namespace metrics |
OLD | NEW |