char* SkArenaAlloc::allocObject(size_t size, size_t alignment) {
size_t mask = alignment - 1;
char* objStart = (char*)((uintptr_t)(fCursor + mask) & ~mask);
- if (objStart + size > fEnd) {
+ if (size > (size_t)(fEnd - objStart)) {
this->ensureSpace(size, alignment);
objStart = (char*)((uintptr_t)(fCursor + mask) & ~mask);
}
char* objStart = (char*)((uintptr_t)(fCursor + skipOverhead + mask) & ~mask);
size_t totalSize = sizeIncludingFooter + skipOverhead;
- if (objStart + totalSize > fEnd) {
+ if (totalSize > (size_t)(fEnd - objStart)) {
this->ensureSpace(totalSize, alignment);
goto restart;
}
template <typename T, typename... Args>
T* make(Args&&... args) {
+ SkASSERT(SkTFitsIn<uint32_t>(sizeof(T)));
char* objStart;
if (skstd::is_trivially_destructible<T>::value) {
objStart = this->allocObject(sizeof(T), alignof(T));