[4/n] BumpPool: fix available size calc
Bug: 177241396
Change-Id: I7ed8958985bb2e2ca4e16d727c3b013a8f550fe4
diff --git a/base/BumpPool.h b/base/BumpPool.h
index e9fceee..302fa60 100644
--- a/base/BumpPool.h
+++ b/base/BumpPool.h
@@ -41,14 +41,14 @@
sizeof(uint64_t) * ((wantedSize + sizeof(uint64_t) - 1) / (sizeof(uint64_t)));
mTotalWantedThisGeneration += wantedSizeRoundedUp;
- if (mAllocPos + wantedSizeRoundedUp > mStorage.size()) {
+ if (mAllocPos + wantedSizeRoundedUp > mStorage.size() * sizeof(uint64_t)) {
mNeedRealloc = true;
void* fallbackPtr = malloc(wantedSizeRoundedUp);
mFallbackPtrs.insert(fallbackPtr);
return fallbackPtr;
}
- size_t avail = mStorage.size() - mAllocPos;
- void* allocPtr = (void*)(mStorage.data() + mAllocPos);
+ size_t avail = mStorage.size() * sizeof(uint64_t) - mAllocPos;
+ void* allocPtr = (void*)(((unsigned char*)mStorage.data()) + mAllocPos);
mAllocPos += wantedSizeRoundedUp;
return allocPtr;
}