Add a default constructor to seqset nodes. (#636)

This allows them to exist as fields without invalidating the set.

This should make it possible to remove the undefined behaviour in the
creation of FrontendSlabMetadata, which is currently created via a
reinterpret_cast from a different-typed allocation.
FrontendSlabMetadata has a SeqSet::Node field that is in an unspecified
state on construction and which is valid only when inserted into a
SeqSet.
This commit is contained in:
David Chisnall
2023-09-18 11:15:49 +01:00
committed by GitHub
parent 2a7670eb82
commit 126e77f2a5

View File

@@ -34,6 +34,9 @@ namespace snmalloc
constexpr Node(Node* next, Node* prev) : next(next), prev(prev) {}
public:
/// Default constructor, creates an invalid node.
constexpr Node() : Node(nullptr, nullptr) {}
void invariant()
{
SNMALLOC_ASSERT(next != nullptr);