Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Unified Diff: base/allocator/allocator_unittests.cc

Issue 10828054: Modify allocator_shim to support _aligned_alloc(), _aligned_free(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Unit tests. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698