MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / make_block

Function make_block

app/src/ThirdParty/readerwriterqueue.h:737–750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

735 };
736
737 static Block* make_block(size_t capacity) AE_NO_TSAN
738 {
739 // Allocate enough memory for the block itself, as well as all the elements
740 // it will contain
741 auto size = sizeof(Block) + std::alignment_of<Block>::value - 1;
742 size += sizeof(T) * capacity + std::alignment_of<T>::value - 1;
743 auto newBlockRaw = static_cast<char*>(std::malloc(size));
744 if (newBlockRaw == nullptr)
745 return nullptr;
746
747 auto newBlockAligned = align_for<Block>(newBlockRaw);
748 auto newBlockData = align_for<T>(newBlockAligned + sizeof(Block));
749 return new (newBlockAligned) Block(capacity, newBlockRaw, newBlockData);
750 }
751
752private:
753 weak_atomic<Block*> frontBlock; // (Atomic) Elements are dequeued from this block

Callers 2

inner_enqueueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected