FlattenableUtils::align memsets am: e62a9d7669 am: 59e7d4e8ea am: 3f273f49f1

am: f7724dfcfb

Change-Id: I0ecdb9a58418d0c65629c70fc6df2a4aad7a1784
This commit is contained in:
Steven Moreland 2019-11-06 16:19:08 -08:00 committed by android-build-merger
commit 4392bca7f7
1 changed files with 6 additions and 1 deletions

View File

@ -47,7 +47,12 @@ public:
template<size_t N>
static size_t align(void*& buffer) {
return align<N>( const_cast<void const*&>(buffer) );
static_assert(!(N & (N - 1)), "Can only align to a power of 2.");
void* b = buffer;
buffer = reinterpret_cast<void*>((uintptr_t(buffer) + (N-1)) & ~(N-1));
size_t delta = size_t(uintptr_t(buffer) - uintptr_t(b));
memset(b, 0, delta);
return delta;
}
static void advance(void*& buffer, size_t& size, size_t offset) {