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

Unified Diff: base/memory/discardable_shared_memory.cc

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
Index: base/memory/discardable_shared_memory.cc
diff --git a/base/memory/discardable_shared_memory.cc b/base/memory/discardable_shared_memory.cc
index 4fd15185ebcf47588004b67697498dcb57e7e810..0f85c1fe903d612ecf055043c1a0d84d362ddbf7 100644
--- a/base/memory/discardable_shared_memory.cc
+++ b/base/memory/discardable_shared_memory.cc
@@ -11,6 +11,7 @@
#include <algorithm>
#include "base/atomicops.h"
+#include "base/bits.h"
#include "base/logging.h"
#include "base/numerics/safe_math.h"
#include "base/process/process_metrics.h"
@@ -89,15 +90,9 @@ SharedState* SharedStateFromSharedMemory(const SharedMemory& shared_memory) {
return static_cast<SharedState*>(shared_memory.memory());
}
-// Round up |size| to a multiple of alignment, which must be a power of two.
-size_t Align(size_t alignment, size_t size) {
- DCHECK_EQ(alignment & (alignment - 1), 0u);
- return (size + alignment - 1) & ~(alignment - 1);
-}
-
// Round up |size| to a multiple of page size.
size_t AlignToPageSize(size_t size) {
- return Align(base::GetPageSize(), size);
+ return bits::Align(size, base::GetPageSize());
}
} // namespace
« base/bits_unittest.cc ('K') | « base/bits_unittest.cc ('k') | base/pickle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698