summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-08-18 14:19:03 +0200
committerMax Kellermann <max@musicpd.org>2017-08-18 14:21:54 +0200
commit9033f0772405168a3c7af37ace448d19b9612d59 (patch)
tree277569f7715e9f6d701ab09f9a623bfc3f0da750 /test
parentb7d0890bc0e92ba65d498c38ff2af8972d3757a3 (diff)
test/{DumpDatabase,run_neighbor_explorer}: add class GlobalInit
Diffstat (limited to 'test')
-rw-r--r--test/DumpDatabase.cxx14
-rw-r--r--test/run_neighbor_explorer.cxx21
2 files changed, 28 insertions, 7 deletions
diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx
index bb778b4ff..c1d289a1c 100644
--- a/test/DumpDatabase.cxx
+++ b/test/DumpDatabase.cxx
@@ -43,6 +43,17 @@ using std::endl;
#include <stdlib.h>
+class GlobalInit {
+public:
+ GlobalInit() {
+ config_global_init();
+ }
+
+ ~GlobalInit() {
+ config_global_finish();
+ }
+};
+
#ifdef ENABLE_UPNP
#include "input/InputStream.hxx"
size_t
@@ -104,8 +115,7 @@ try {
/* initialize MPD */
- config_global_init();
- AtScopeExit() { config_global_finish(); };
+ GlobalInit init;
ReadConfigFile(config_path);
diff --git a/test/run_neighbor_explorer.cxx b/test/run_neighbor_explorer.cxx
index 399e806aa..f07f1af21 100644
--- a/test/run_neighbor_explorer.cxx
+++ b/test/run_neighbor_explorer.cxx
@@ -29,6 +29,17 @@
#include <stdio.h>
#include <stdlib.h>
+class GlobalInit {
+public:
+ GlobalInit() {
+ config_global_init();
+ }
+
+ ~GlobalInit() {
+ config_global_finish();
+ }
+};
+
class MyNeighborListener final : public NeighborListener {
public:
/* virtual methods from class NeighborListener */
@@ -53,15 +64,15 @@ try {
const Path config_path = Path::FromFS(argv[1]);
- /* read configuration file (mpd.conf) */
-
- config_global_init();
- ReadConfigFile(config_path);
-
/* initialize the core */
+ GlobalInit init;
EventLoop loop;
+ /* read configuration file (mpd.conf) */
+
+ ReadConfigFile(config_path);
+
/* initialize neighbor plugins */
MyNeighborListener listener;