Commit 3c9a7ffa authored by Bartek Nowierski's avatar Bartek Nowierski Committed by Commit Bot

More GetAllocatedSize disambiguation

Continuation of crrev.com/c/2455947

Change-Id: I31507f9c386803dc1a379177cc62472fe674ba48
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463043
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Auto-Submit: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815498}
parent a8b9fd2b
......@@ -588,15 +588,15 @@ TEST_F(AllocatorShimTest, ShimReplacesCRTHeapWhenEnabled) {
#endif // defined(OS_WIN)
#if defined(OS_WIN)
static size_t GetAllocatedSize(void* ptr) {
static size_t GetUsableSize(void* ptr) {
return _msize(ptr);
}
#elif defined(OS_APPLE)
static size_t GetAllocatedSize(void* ptr) {
static size_t GetUsableSize(void* ptr) {
return malloc_size(ptr);
}
#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
static size_t GetAllocatedSize(void* ptr) {
static size_t GetUsableSize(void* ptr) {
return malloc_usable_size(ptr);
}
#else
......@@ -606,17 +606,17 @@ static size_t GetAllocatedSize(void* ptr) {
#if !defined(NO_MALLOC_SIZE)
TEST_F(AllocatorShimTest, ShimReplacesMallocSizeWhenEnabled) {
InsertAllocatorDispatch(&g_mock_dispatch);
EXPECT_EQ(GetAllocatedSize(kTestSizeEstimateAddress), kTestSizeEstimate);
EXPECT_EQ(GetUsableSize(kTestSizeEstimateAddress), kTestSizeEstimate);
RemoveAllocatorDispatchForTesting(&g_mock_dispatch);
}
TEST_F(AllocatorShimTest, ShimDoesntChangeMallocSizeWhenEnabled) {
void* alloc = malloc(16);
size_t sz = GetAllocatedSize(alloc);
size_t sz = GetUsableSize(alloc);
EXPECT_GE(sz, 16U);
InsertAllocatorDispatch(&g_mock_dispatch);
EXPECT_EQ(GetAllocatedSize(alloc), sz);
EXPECT_EQ(GetUsableSize(alloc), sz);
RemoveAllocatorDispatchForTesting(&g_mock_dispatch);
free(alloc);
......
......@@ -2579,7 +2579,7 @@ TEST_F(PartitionAllocTest, OptimizedGetSlotOffset) {
}
}
TEST_F(PartitionAllocTest, GetAllocatedSize) {
TEST_F(PartitionAllocTest, GetUsableSize) {
size_t delta = SystemPageSize() + 1;
for (size_t size = 1; size <= kMinDirectMappedDownsize; size += delta) {
void* ptr = allocator.root()->Alloc(size, "");
......
......@@ -28,17 +28,17 @@
#if defined(OS_WIN)
#include <malloc.h>
static size_t GetAllocatedSize(void* mem) {
static size_t GetUsableSize(void* mem) {
return _msize(mem);
}
#elif defined(OS_APPLE)
#include <malloc/malloc.h>
static size_t GetAllocatedSize(void* mem) {
static size_t GetUsableSize(void* mem) {
return malloc_size(mem);
}
#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
#include <malloc.h>
static size_t GetAllocatedSize(void* mem) {
static size_t GetUsableSize(void* mem) {
return malloc_usable_size(mem);
}
#endif
......@@ -257,7 +257,7 @@ MULTIPROCESS_TEST_MAIN_WITH_SETUP(
std::unique_ptr<void, decltype(&free)> alloc(malloc(kAllocationSize), free);
CHECK_NE(alloc.get(), nullptr);
size_t alloc_sz = GetAllocatedSize(alloc.get());
size_t alloc_sz = GetUsableSize(alloc.get());
if (GetMallocGpaForTesting().PointerIsMine(alloc.get()))
CHECK_EQ(alloc_sz, kAllocationSize);
else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment