From 241268431699f34884d4d0cba11b8c84ce5170ad Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Thu, 21 Nov 2024 10:35:05 -0800 Subject: [PATCH] childMaxVersion memory needs to be defined Also remove some dead code, and only memset children to 0 for Node256. Other nodes detect absence of children other ways. --- ConflictSet.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index ca0ae82..15889d8 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -692,16 +692,6 @@ static_assert(kBytesPerKey - sizeof(Node0) >= kMinNodeSurplus); // Which should give us the budget to pay for the key bytes. (children + // entryPresent) is a lower bound on how many keys these bytes are a prefix of -constexpr int getMaxCapacity(int numChildren, int entryPresent, - int partialKeyLen) { - return (numChildren + entryPresent) * (partialKeyLen + 1); -} - -constexpr int getMaxCapacity(Node *self) { - return getMaxCapacity(self->numChildren, self->entryPresent, - self->partialKeyLen); -} - template struct NodeAllocator { static_assert(std::derived_from); @@ -712,12 +702,14 @@ template struct NodeAllocator { result->endOfRange = false; result->releaseDeferred = false; if constexpr (!std::is_same_v) { - memset(result->children, 0, sizeof(result->children)); const auto z = InternalVersionT::zero; for (auto &v : result->childMaxVersion) { v = z; } } + if constexpr (std::is_same_v) { + memset(result->children, 0, sizeof(result->children)); + } if constexpr (std::is_same_v || std::is_same_v) { const auto z = InternalVersionT::zero; for (auto &v : result->maxOfMax) { @@ -1973,8 +1965,6 @@ Node *erase(Node *self, WriteContext *writeContext, ConflictSet::Impl *impl, sizeof(parent3->index[0])); VALGRIND_MAKE_MEM_UNDEFINED(parent3->children + parent3->numChildren, sizeof(parent3->children[0])); - VALGRIND_MAKE_MEM_UNDEFINED(parent3->childMaxVersion + parent3->numChildren, - sizeof(parent3->childMaxVersion[0])); if (needsDownsize(parent3)) { downsize(parent3, writeContext, impl); @@ -1994,9 +1984,6 @@ Node *erase(Node *self, WriteContext *writeContext, ConflictSet::Impl *impl, sizeof(parent16->index[0])); VALGRIND_MAKE_MEM_UNDEFINED(parent16->children + parent16->numChildren, sizeof(parent16->children[0])); - VALGRIND_MAKE_MEM_UNDEFINED(parent16->childMaxVersion + - parent16->numChildren, - sizeof(parent16->childMaxVersion[0])); if (needsDownsize(parent16)) { downsize(parent16, writeContext, impl);