if (size < 64 * KB) {
size = 64 * KB;
}
- size = RoundUp(size, GetAllocationGranularity());
+ size = RoundUp(size, GetPageSize());
LPVOID address = NULL;
// Try and randomize the allocation address (up to three attempts).
for (unsigned attempts = 0; address == NULL && attempts < 3; ++attempts) {
ASSERT_NE(NULL, size_return);
ASSERT(IsAligned(alignment, GetAllocationGranularity()));
- size_t reserved_size;
+ size_t reserved_size = RoundUp(size + alignment, GetAllocationGranularity());
Address reserved_base = static_cast<Address>(
- ReserveRegion(size + alignment, &reserved_size));
+ ReserveRegion(reserved_size, &reserved_size));
if (reserved_base == NULL) {
return NULL;
}
ASSERT_LE(size, reserved_size);
+ ASSERT_LE(size + alignment, reserved_size);
ASSERT(IsAligned(reserved_size, GetPageSize()));
// Try reducing the size by freeing and then reallocating a specific area.
}
// Resizing failed, just go with a bigger area.
+ ASSERT(IsAligned(reserved_size, GetAllocationGranularity()));
return ReserveRegion(reserved_size, size_return);
}
allocation_granularity = system_info.dwAllocationGranularity;
MemoryBarrier();
}
+ ASSERT_GE(allocation_granularity, GetPageSize());
return allocation_granularity;
}