| Index: base/metrics/persistent_memory_allocator.cc
|
| diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc
|
| index 672ef974634700343a4be0505c349029a6ec4a0d..4e6b7ef4d2191d6c939a3aa99b0e657ee202b292 100644
|
| --- a/base/metrics/persistent_memory_allocator.cc
|
| +++ b/base/metrics/persistent_memory_allocator.cc
|
| @@ -453,6 +453,24 @@ size_t PersistentMemoryAllocator::used() const {
|
| mem_size_);
|
| }
|
|
|
| +PersistentMemoryAllocator::Reference PersistentMemoryAllocator::GetAsReference(
|
| + const void* memory,
|
| + uint32_t type_id) const {
|
| + uintptr_t address = reinterpret_cast<uintptr_t>(memory);
|
| + if (address < reinterpret_cast<uintptr_t>(mem_base_))
|
| + return kReferenceNull;
|
| +
|
| + uintptr_t offset = address - reinterpret_cast<uintptr_t>(mem_base_);
|
| + if (offset >= mem_size_ || offset < sizeof(BlockHeader))
|
| + return kReferenceNull;
|
| +
|
| + Reference ref = static_cast<Reference>(offset) - sizeof(BlockHeader);
|
| + if (!GetBlockData(ref, type_id, kSizeAny))
|
| + return kReferenceNull;
|
| +
|
| + return ref;
|
| +}
|
| +
|
| size_t PersistentMemoryAllocator::GetAllocSize(Reference ref) const {
|
| const volatile BlockHeader* const block = GetBlock(ref, 0, 0, false, false);
|
| if (!block)
|
|
|