21 : fFibProgression(
size, firstHeapAllocation) {
25 std::size_t space =
size;
27 if (bytes && std::align(kMaxAlignment,
sizeof(
Block), ptr, space)) {
28 this->setupBytesAndCapacity(bytes,
size);
29 new (fEndByte)
Block(
nullptr,
nullptr);
34 :
BagOfBytes(nullptr, 0, firstHeapAllocation) {}
37 Block* cursor =
reinterpret_cast<Block*
>(fEndByte);
38 while (cursor !=
nullptr) {
39 char* toDelete = cursor->fBlockStart;
40 cursor = cursor->fPrevious;
45BagOfBytes::Block::Block(
char* previous,
char* startOfBlock)
46 : fBlockStart{startOfBlock}
47 , fPrevious{reinterpret_cast<
Block*>(previous)} {}
54 return this->allocateBytes(
size, alignment);
57void BagOfBytes::setupBytesAndCapacity(
char* bytes,
int size) {
60 intptr_t endByte =
reinterpret_cast<intptr_t
>(bytes +
size -
sizeof(
Block)) & -kMaxAlignment;
61 fEndByte =
reinterpret_cast<char*
>(endByte);
62 fCapacity = fEndByte - bytes;
65void BagOfBytes::needMoreBytes(
int requestedSize,
int alignment) {
68 std::max(requestedSize, nextBlockSize), kAllocationAlignment);
69 char*
const bytes =
new char[
size];
71 char*
const previousBlock = fEndByte;
72 this->setupBytesAndCapacity(bytes,
size);
75 new (fEndByte)
Block{previousBlock, bytes};
78 fCapacity = fCapacity & -alignment;
79 SkASSERT(fCapacity >= requestedSize);
84 : fAlloc{bytes,
SkTo<size_t>(
size),
SkTo<size_t>(firstHeapAllocation)} {
#define SkASSERT_RELEASE(cond)
SkBlockAllocator::Block Block
constexpr bool SkIsPow2(T value)
void * alignedBytes(int unsafeSize, int unsafeAlignment)
BagOfBytes(char *block, size_t blockSize, size_t firstHeapAllocation)
static constexpr int PlatformMinimumSizeWithOverhead(int requestedSize, int assumedAlignment)
void * alignedBytes(int size, int alignment)
SubRunAllocator(char *block, int blockSize, int firstHeapAllocation)