diff options
Diffstat (limited to 'src/malloc_extension.cc')
-rw-r--r-- | src/malloc_extension.cc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/malloc_extension.cc b/src/malloc_extension.cc index e9a0da7..bf946e6 100644 --- a/src/malloc_extension.cc +++ b/src/malloc_extension.cc @@ -48,6 +48,7 @@ #include "google/heap-checker.h" #endif #include "google/malloc_extension.h" +#include "google/malloc_extension_c.h" #include "maybe_threads.h" using STL_NAMESPACE::string; @@ -177,9 +178,14 @@ size_t MallocExtension::GetEstimatedAllocatedSize(size_t size) { } size_t MallocExtension::GetAllocatedSize(void* p) { + assert(GetOwnership(p) != kNotOwned); return 0; } +MallocExtension::Ownership MallocExtension::GetOwnership(const void* p) { + return kUnknownOwnership; +} + void MallocExtension::GetFreeListSizes( vector<MallocExtension::FreeListInfo>* v) { v->clear(); @@ -238,11 +244,11 @@ void PrintCountAndSize(MallocExtensionWriter* writer, uintptr_t count, uintptr_t size) { char buf[100]; snprintf(buf, sizeof(buf), - "%6lld: %8lld [%6lld: %8lld] @", - static_cast<long long>(count), - static_cast<long long>(size), - static_cast<long long>(count), - static_cast<long long>(size)); + "%6"PRIu64": %8"PRIu64" [%6"PRIu64": %8"PRIu64"] @", + static_cast<uint64>(count), + static_cast<uint64>(size), + static_cast<uint64>(count), + static_cast<uint64>(size)); writer->append(buf, strlen(buf)); } @@ -357,3 +363,10 @@ C_SHIM(ReleaseFreeMemory, void, (void), ()); C_SHIM(ReleaseToSystem, void, (size_t num_bytes), (num_bytes)); C_SHIM(GetEstimatedAllocatedSize, size_t, (size_t size), (size)); C_SHIM(GetAllocatedSize, size_t, (void* p), (p)); + +// Can't use the shim here because of the need to translate the enums. +extern "C" +MallocExtension_Ownership MallocExtension_GetOwnership(const void* p) { + return static_cast<MallocExtension_Ownership>( + MallocExtension::instance()->GetOwnership(p)); +} |