Require that eraseBetween leave at least one child or entryPresent

This commit is contained in:
2024-08-15 11:37:36 -07:00
parent 403d70a1d3
commit 6242f40d48

View File

@@ -1922,7 +1922,9 @@ void eraseBetween(Node **inTree, Node256 *n, int begin, int end,
}
// Erase all nodes with a search path starting with n + [child],
// where child in [begin, end).
// where child in [begin, end). To avoid the need to propagate erases up the
// search path, the caller must ensure that the result has at least one child or
// has entryPresent.
void eraseBetween(Node *&n, int begin, int end, WriteContext *tls) {
#if DEBUG_VERBOSE && !defined(NDEBUG)
fprintf(stderr, "eraseBetween: %s + [%d,%d)\n",
@@ -1946,6 +1948,7 @@ void eraseBetween(Node *&n, int begin, int end, WriteContext *tls) {
default: // GCOVR_EXCL_LINE
__builtin_unreachable(); // GCOVR_EXCL_LINE
}
assert(n->numChildren > 0 || n->entryPresent);
}
// Precondition: self is not the root. May invalidate nodes along the search