summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-07 22:42:29 +0100
committerDavid Robillard <d@drobilla.net>2019-03-08 09:08:16 +0100
commitce3f3aff9c27f902c6b6b5a0f8d9bdc3dfb26c3f (patch)
tree4608634b1b306c8cf27c5a9ed97f445b5ca3fa91 /tests
parent8eba534e99cd8db29cca03035a115312935a22a3 (diff)
downloadingen-ce3f3aff9c27f902c6b6b5a0f8d9bdc3dfb26c3f.tar.gz
ingen-ce3f3aff9c27f902c6b6b5a0f8d9bdc3dfb26c3f.tar.bz2
ingen-ce3f3aff9c27f902c6b6b5a0f8d9bdc3dfb26c3f.zip
Use smart pointers to manage World in programs
Diffstat (limited to 'tests')
-rw-r--r--tests/ingen_bench.cpp7
-rw-r--r--tests/ingen_test.cpp7
2 files changed, 6 insertions, 8 deletions
diff --git a/tests/ingen_bench.cpp b/tests/ingen_bench.cpp
index b51ec364..1a0d84ca 100644
--- a/tests/ingen_bench.cpp
+++ b/tests/ingen_bench.cpp
@@ -35,14 +35,14 @@
using namespace std;
using namespace ingen;
-World* world = nullptr;
+unique_ptr<World> world;
static void
ingen_try(bool cond, const char* msg)
{
if (!cond) {
cerr << "ingen: Error: " << msg << endl;
- delete world;
+ world.reset();
exit(EXIT_FAILURE);
}
}
@@ -63,7 +63,7 @@ main(int argc, char** argv)
// Create world
try {
- world = new World(nullptr, nullptr, nullptr);
+ world = unique_ptr<World>{new World(nullptr, nullptr, nullptr)};
world->conf().add(
"output", "output", 'O', "File to write benchmark output",
ingen::Configuration::SESSION, world->forge().String, Atom());
@@ -135,6 +135,5 @@ main(int argc, char** argv)
// Shut down
world->engine()->deactivate();
- delete world;
return EXIT_SUCCESS;
}
diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp
index 3a566084..f40499b4 100644
--- a/tests/ingen_test.cpp
+++ b/tests/ingen_test.cpp
@@ -51,14 +51,14 @@
using namespace std;
using namespace ingen;
-World* world = nullptr;
+unique_ptr<World> world;
static void
ingen_try(bool cond, const char* msg)
{
if (!cond) {
cerr << "ingen: Error: " << msg << endl;
- delete world;
+ world.reset();
exit(EXIT_FAILURE);
}
}
@@ -70,7 +70,7 @@ main(int argc, char** argv)
// Create world
try {
- world = new World(nullptr, nullptr, nullptr);
+ world = unique_ptr<World>{new World(nullptr, nullptr, nullptr)};
world->load_configuration(argc, argv);
} catch (std::exception& e) {
cout << "ingen: " << e.what() << endl;
@@ -218,6 +218,5 @@ main(int argc, char** argv)
// Shut down
world->engine()->deactivate();
- delete world;
return EXIT_SUCCESS;
}