void BagOfBytes::setupBytesAndCapacity(char* bytes, int size) { // endByte must be aligned to the maximum alignment to allow tracking alignment using capacity; // capacity and endByte are both aligned to max alignment.
intptr_t endByte = reinterpret_cast<intptr_t>(bytes + size - sizeof(Block)) & -kMaxAlignment;
fEndByte = reinterpret_cast<char*>(endByte);
fCapacity = fEndByte - bytes;
}
void BagOfBytes::needMoreBytes(int requestedSize, int alignment) { int nextBlockSize = fFibProgression.nextBlockSize(); constint size = PlatformMinimumSizeWithOverhead(
std::max(requestedSize, nextBlockSize), kAllocationAlignment); char* const bytes = newchar[size]; // fEndByte is changed by setupBytesAndCapacity. Remember it to link back to. char* const previousBlock = fEndByte;
this->setupBytesAndCapacity(bytes, size);
// Make a block to delete these bytes, and points to the previous block. new (fEndByte) Block{previousBlock, bytes};
// Make fCapacity the alignment for the requested object.
fCapacity = fCapacity & -alignment;
SkASSERT(fCapacity >= requestedSize);
}
// -- SubRunAllocator ----------------------------------------------------------------------------
SubRunAllocator::SubRunAllocator(char* bytes, int size, int firstHeapAllocation)
: fAlloc{bytes, SkTo<size_t>(size), SkTo<size_t>(firstHeapAllocation)} {
SkASSERT_RELEASE(SkTFitsIn<size_t>(size));
SkASSERT_RELEASE(SkTFitsIn<size_t>(firstHeapAllocation));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.