diff options
author | Max Kellermann <max@duempel.org> | 2013-01-30 16:35:24 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-30 16:41:17 +0100 |
commit | f7d8e6c40c9adb7ae904dac4d887807bb0d17b68 (patch) | |
tree | 7a059e19666007c5000e4879eb213a10e3cd2c3b /src/InotifyUpdate.cxx | |
parent | 4ecf09f9e6cde4948246194173350ddca6de0451 (diff) | |
download | mpd-f7d8e6c40c9adb7ae904dac4d887807bb0d17b68.tar.gz mpd-f7d8e6c40c9adb7ae904dac4d887807bb0d17b68.tar.xz mpd-f7d8e6c40c9adb7ae904dac4d887807bb0d17b68.zip |
InotifyUpdate: allocate the root dynamically
Diffstat (limited to 'src/InotifyUpdate.cxx')
-rw-r--r-- | src/InotifyUpdate.cxx | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/InotifyUpdate.cxx b/src/InotifyUpdate.cxx index 37b2107dd..2e7adb3fc 100644 --- a/src/InotifyUpdate.cxx +++ b/src/InotifyUpdate.cxx @@ -56,7 +56,6 @@ struct WatchDirectory { GList *children; - WatchDirectory() = default; WatchDirectory(WatchDirectory *_parent, const char *_name, int _descriptor) :parent(_parent), name(g_strdup(_name)), @@ -68,7 +67,7 @@ static InotifySource *inotify_source; static InotifyQueue *inotify_queue; static unsigned inotify_max_depth; -static WatchDirectory inotify_root; +static WatchDirectory *inotify_root; static std::map<int, WatchDirectory *> inotify_directories; static void @@ -322,10 +321,8 @@ mpd_inotify_init(unsigned max_depth) inotify_max_depth = max_depth; - inotify_root.name = g_strdup(path.c_str()); - inotify_root.descriptor = inotify_source->Add(path.c_str(), - IN_MASK, &error); - if (inotify_root.descriptor < 0) { + int descriptor = inotify_source->Add(path.c_str(), IN_MASK, &error); + if (descriptor < 0) { g_warning("%s", error->message); g_error_free(error); delete inotify_source; @@ -333,9 +330,11 @@ mpd_inotify_init(unsigned max_depth) return; } - tree_add_watch_directory(&inotify_root); + inotify_root = new WatchDirectory(nullptr, path.c_str(), descriptor); - recursive_watch_subdirectories(&inotify_root, path.c_str(), 0); + tree_add_watch_directory(inotify_root); + + recursive_watch_subdirectories(inotify_root, path.c_str(), 0); inotify_queue = new InotifyQueue(*main_loop); @@ -357,8 +356,7 @@ mpd_inotify_finish(void) g_free(directory->name); g_list_free(directory->children); - if (directory != &inotify_root) - delete directory; + delete directory; } inotify_directories.clear(); |