diff --git a/ConflictSet.cpp b/ConflictSet.cpp index a92f147..23eb785 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -349,6 +349,19 @@ void rotate(Node **node, bool dir) { updateMaxVersion(l); } +void checkParentPointers(Node *node, bool &success) { + for (int i = 0; i < 2; ++i) { + if (node->child[i] != nullptr) { + if (node->child[i]->parent != node) { + fprintf(stderr, "%.*s child %d has parent pointer %p. Expected %p\n", + node->len, (const char *)(node + 1), i, + (void *)node->child[i]->parent, (void *)node); + } + checkParentPointers(node->child[i], success); + } + } +} + int64_t checkMaxVersion(Node *node, bool &success) { int64_t expected = std::max(node->pointVersion, node->rangeVersion); for (int i = 0; i < 2; ++i) { @@ -385,6 +398,7 @@ bool checkInvariants(Node *node) { assert(std::is_sorted(keys.begin(), keys.end())); checkMaxVersion(node, success); + checkParentPointers(node, success); // TODO Compare logical contents of map with // reference implementation