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

Unified Diff: base/bits.h

Issue 1249643007: Align base::Pickle allocations to 4k boundaries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@accounting_fix
Patch Set: Nits test Created 5 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
« no previous file with comments | « no previous file | base/bits_unittest.cc » ('j') | base/bits_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/bits.h
diff --git a/base/bits.h b/base/bits.h
index b2209e8ed7934a6dfc918c3d7d12b9c455f594e1..505d2c8f75d901688186ed2e1f981b3a9a2562bc 100644
--- a/base/bits.h
+++ b/base/bits.h
@@ -41,6 +41,12 @@ inline int Log2Ceiling(uint32 n) {
}
}
+// Round up |size| to a multiple of alignment, which must be a power of two.
+inline size_t Align(size_t size, size_t alignment) {
+ DCHECK_EQ(alignment & (alignment - 1), 0u);
+ return (size + alignment - 1) & ~(alignment - 1);
+}
+
} // namespace bits
} // namespace base
« no previous file with comments | « no previous file | base/bits_unittest.cc » ('j') | base/bits_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698