diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 58b7637..3873ba5 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -162,6 +162,15 @@ template struct ArenaAlloc { private: }; +template using Vector = std::vector>; +template auto vector(Arena &arena) { + return Vector(ArenaAlloc(&arena)); +} +template using Set = std::set, ArenaAlloc>; +template auto set(Arena &arena) { + return Set(ArenaAlloc(&arena)); +} + template bool operator==(const ArenaAlloc &lhs, const ArenaAlloc &rhs) { return lhs.arena == rhs.arena; @@ -843,8 +852,7 @@ bool checkCorrectness(Node *node, ReferenceImpl &refImpl) { bool success = true; // Check bst invariant Arena arena; - std::vector> keys{ - ArenaAlloc(&arena)}; + auto keys = vector(arena); for (auto iter = extrema(node, false); iter != nullptr; iter = next(iter, true)) { keys.push_back(std::string_view((char *)(iter + 1), iter->len)); @@ -998,8 +1006,7 @@ struct __attribute__((__visibility__("hidden"))) ConflictSet::Impl { runInterleaved(stepwiseInserts); - std::vector> workList{ - ArenaAlloc(&arena)}; + auto workList = vector(arena); workList.reserve(count); for (int i = 0; i < count; ++i) { Node *node = *stepwiseInserts[i].current; @@ -1048,7 +1055,7 @@ struct __attribute__((__visibility__("hidden"))) ConflictSet::Impl { ~Impl() { Arena arena; - std::vector> toFree{ArenaAlloc(&arena)}; + auto toFree = vector(arena); if (root != nullptr) { toFree.push_back(root); } @@ -1240,9 +1247,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { int numWrites = gArbitrary.bounded(10); int64_t v = ++writeVersion; auto *writes = new (arena) ConflictSet::WriteRange[numWrites]; - std::set, - ArenaAlloc> - keys{ArenaAlloc(&arena)}; + auto keys = set(arena); while (int(keys.size()) < numWrites) { if (!gArbitrary.hasEntropy()) { // Tell the fuzzer it's not interesting @@ -1271,9 +1276,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { int numReads = gArbitrary.bounded(10); int64_t v = writeVersion - gArbitrary.bounded(10); auto *reads = new (arena) ConflictSet::ReadRange[numReads]; - std::set, - ArenaAlloc> - keys{ArenaAlloc(&arena)}; + auto keys = set(arena); while (int(keys.size()) < numReads) { if (!gArbitrary.hasEntropy()) { // Tell the fuzzer it's not interesting