MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / initializeFixedStorage

Method initializeFixedStorage

Libraries/Await/Await.cpp:385–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383}
384
385Result 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
407void* AwaitAllocator::allocateFromBlocks(const void*, size_t numBytes, size_t alignment)
408{

Callers

nothing calls this directly

Calls 4

alignPointerFunction · 0.85
ResultClass · 0.50
dataMethod · 0.45
sizeInBytesMethod · 0.45

Tested by

no test coverage detected