| 383 | } |
| 384 | |
| 385 | Result AwaitAllocator::initializeFixedStorage(Span<char> storage) |
| 386 | { |
| 387 | char* base = storage.data(); |
| 388 | char* storageEnd = base + storage.sizeInBytes(); |
| 389 | char* alignedBase = static_cast<char*>(alignPointer(base, alignof(BlockHeader))); |
| 390 | if (alignedBase >= storageEnd or static_cast<size_t>(storageEnd - alignedBase) < sizeof(BlockHeader)) |
| 391 | { |
| 392 | fixedStorage = storage; |
| 393 | firstBlock = nullptr; |
| 394 | return Result(true); |
| 395 | } |
| 396 | |
| 397 | fixedStorage = storage; |
| 398 | firstBlock = reinterpret_cast<BlockHeader*>(alignedBase); |
| 399 | firstBlock->allocator = this; |
| 400 | firstBlock->previous = nullptr; |
| 401 | firstBlock->next = nullptr; |
| 402 | firstBlock->blockBytes = static_cast<size_t>(storageEnd - alignedBase); |
| 403 | firstBlock->free = true; |
| 404 | return Result(true); |
| 405 | } |
| 406 | |
| 407 | void* AwaitAllocator::allocateFromBlocks(const void*, size_t numBytes, size_t alignment) |
| 408 | { |
nothing calls this directly
no test coverage detected