about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorDaniel Schemmel <daniel@schemmel.net>2023-03-24 00:54:38 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2023-04-21 13:07:31 +0100
commitad61b674eef24d63f4514b3798f0d215c3080579 (patch)
tree2a05ad0cf12ec71762989992e1e7d8b8b664bbb2 /lib
parent4ccb3fe8df5babec7480b433b38da265de73a8eb (diff)
downloadklee-ad61b674eef24d63f4514b3798f0d215c3080579.tar.gz
use unique_ptr in ValidatingSolver
Diffstat (limited to 'lib')
-rw-r--r--lib/Solver/ValidatingSolver.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/Solver/ValidatingSolver.cpp b/lib/Solver/ValidatingSolver.cpp
index d95b8942..72bdc830 100644
--- a/lib/Solver/ValidatingSolver.cpp
+++ b/lib/Solver/ValidatingSolver.cpp
@@ -11,24 +11,22 @@
 #include "klee/Solver/Solver.h"
 #include "klee/Solver/SolverImpl.h"
 
+#include <memory>
 #include <vector>
 
 namespace klee {
 
 class ValidatingSolver : public SolverImpl {
 private:
-  Solver *solver, *oracle;
-  bool ownsOracle;
+  std::unique_ptr<Solver> solver;
+  std::unique_ptr<Solver, void(*)(Solver*)> oracle;
 
 public:
   ValidatingSolver(Solver *solver, Solver *oracle, bool ownsOracle = false)
-      : solver(solver), oracle(oracle), ownsOracle(ownsOracle) {}
-  ~ValidatingSolver() {
-    delete solver;
-    if (ownsOracle) {
-      delete oracle;
-    }
-  }
+      : solver(solver),
+        oracle(
+            oracle, ownsOracle ? [](Solver *solver) { delete solver; }
+                               : [](Solver *) {}) {}
 
   bool computeValidity(const Query &, Solver::Validity &result);
   bool computeTruth(const Query &, bool &isValid);