summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-03-18 22:53:16 +0100
committerMax Kellermann <max@duempel.org>2016-03-18 22:53:16 +0100
commit6190da1300b4fb0f1d6724ee2e8466fc89b601c1 (patch)
treedf889e148035e2a6231b8fb15b7f035a232a9b68 /test
parent6fd7d8191eddd96b2b92a4ec30659d85814dc0ba (diff)
test/DumpDatabase: use AtScopeExit()
Diffstat (limited to 'test')
-rw-r--r--test/DumpDatabase.cxx16
1 files changed, 6 insertions, 10 deletions
diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx
index a6673f581..5032cab69 100644
--- a/test/DumpDatabase.cxx
+++ b/test/DumpDatabase.cxx
@@ -34,6 +34,7 @@
#include "event/Loop.hxx"
#include "Log.hxx"
#include "util/Error.hxx"
+#include "util/ScopeExit.hxx"
#include <iostream>
using std::cout;
@@ -108,6 +109,7 @@ try {
/* initialize MPD */
config_global_init();
+ AtScopeExit() { config_global_finish(); };
Error error;
ReadConfigFile(config_path);
@@ -132,29 +134,23 @@ try {
return EXIT_FAILURE;
}
+ AtScopeExit(db) { delete db; };
+
if (!db->Open(error)) {
- delete db;
cerr << error.GetMessage() << endl;
return EXIT_FAILURE;
}
+ AtScopeExit(db) { db->Close(); };
+
const DatabaseSelection selection("", true);
if (!db->Visit(selection, DumpDirectory, DumpSong, DumpPlaylist,
error)) {
- db->Close();
- delete db;
cerr << error.GetMessage() << endl;
return EXIT_FAILURE;
}
- db->Close();
- delete db;
-
- /* deinitialize everything */
-
- config_global_finish();
-
return EXIT_SUCCESS;
} catch (const std::exception &e) {
LogError(e);