diff options
author | David Robillard <d@drobilla.net> | 2019-03-07 22:42:29 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-03-08 09:08:16 +0100 |
commit | ce3f3aff9c27f902c6b6b5a0f8d9bdc3dfb26c3f (patch) | |
tree | 4608634b1b306c8cf27c5a9ed97f445b5ca3fa91 | |
parent | 8eba534e99cd8db29cca03035a115312935a22a3 (diff) | |
download | ingen-ce3f3aff9c27f902c6b6b5a0f8d9bdc3dfb26c3f.tar.gz ingen-ce3f3aff9c27f902c6b6b5a0f8d9bdc3dfb26c3f.tar.bz2 ingen-ce3f3aff9c27f902c6b6b5a0f8d9bdc3dfb26c3f.zip |
Use smart pointers to manage World in programs
-rw-r--r-- | src/ingen/ingen.cpp | 2 | ||||
-rw-r--r-- | tests/ingen_bench.cpp | 7 | ||||
-rw-r--r-- | tests/ingen_test.cpp | 7 |
3 files changed, 7 insertions, 9 deletions
diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp index 62dd83ba..bc47d433 100644 --- a/src/ingen/ingen.cpp +++ b/src/ingen/ingen.cpp @@ -48,7 +48,7 @@ class DummyInterface : public Interface void message(const Message& msg) override {} }; -unique_ptr<ingen::World> world; +unique_ptr<World> world; static void ingen_interrupt(int signal) 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; } |