Chromium Code Reviews| Index: base/allocator/allocator_unittests.cc |
| diff --git a/base/allocator/allocator_unittests.cc b/base/allocator/allocator_unittests.cc |
| index a40afdf99f0e22f2be85ffa51bc58fcd866b65b6..30bc411b02d3317bff706a3baa724e8559994afa 100644 |
| --- a/base/allocator/allocator_unittests.cc |
| +++ b/base/allocator/allocator_unittests.cc |
| @@ -479,6 +479,23 @@ TEST(Allocators, Recalloc) { |
| } |
| } |
| } |
| + |
| +// Test windows specific _aligned_malloc() and _aligned_free() methods. |
| +TEST(Allocators, AlignedMalloc) { |
| + // Try allocating data with a bunch of alignments and sizes |
| + static const int kTestAlignments[] = {8, 16, 256, 4096}; |
| + for (int size = 1; size < 1048576; size *= 2) { |
|
jar (doing other things)
2012/07/30 23:04:22
By accident, tcmalloc will tend(?) to pass this te
DaleCurtis
2012/07/31 00:44:22
Added 8192, 16384 alignments and allocate two per
|
| + for (int i = 0; i < ARRAYSIZE(kTestAlignments); ++i) { |
| + unsigned char* ptr = reinterpret_cast<unsigned char*>( |
| + _aligned_malloc(size, kTestAlignments[i])); |
|
jar (doing other things)
2012/07/30 23:04:22
I'd also suggest you allocate "size + 1" to avoid
DaleCurtis
2012/07/31 00:44:22
Switched to using NextSize() as many of the other
|
| + CheckAlignment(ptr, kTestAlignments[i]); |
| + Fill(ptr, size); |
| + EXPECT_TRUE(Valid(ptr, size)); |
| + _aligned_free(ptr); |
| + } |
| + } |
| +} |
| + |
| #endif |