From 4ecf09f9e6cde4948246194173350ddca6de0451 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Jan 2013 16:35:56 +0100 Subject: InotifyUpdate: use new/delete instead of GLib slices --- src/InotifyUpdate.cxx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/InotifyUpdate.cxx') diff --git a/src/InotifyUpdate.cxx b/src/InotifyUpdate.cxx index 734f46a06..37b2107dd 100644 --- a/src/InotifyUpdate.cxx +++ b/src/InotifyUpdate.cxx @@ -55,6 +55,13 @@ struct WatchDirectory { int descriptor; GList *children; + + WatchDirectory() = default; + WatchDirectory(WatchDirectory *_parent, const char *_name, + int _descriptor) + :parent(_parent), name(g_strdup(_name)), + descriptor(_descriptor), + children(nullptr) {} }; static InotifySource *inotify_source; @@ -112,7 +119,7 @@ remove_watch_directory(WatchDirectory *directory) inotify_source->Remove(directory->descriptor); g_free(directory->name); - g_slice_free(WatchDirectory, directory); + delete directory; } static char * @@ -169,7 +176,6 @@ recursive_watch_subdirectories(WatchDirectory *directory, char *child_path_fs; struct stat st; int ret; - WatchDirectory *child; if (skip_path(ent->d_name)) continue; @@ -198,18 +204,14 @@ recursive_watch_subdirectories(WatchDirectory *directory, continue; } - child = tree_find_watch_directory(ret); + WatchDirectory *child = tree_find_watch_directory(ret); if (child != NULL) { /* already being watched */ g_free(child_path_fs); continue; } - child = g_slice_new(WatchDirectory); - child->parent = directory; - child->name = g_strdup(ent->d_name); - child->descriptor = ret; - child->children = NULL; + child = new WatchDirectory(directory, ent->d_name, ret); directory->children = g_list_prepend(directory->children, child); @@ -356,7 +358,7 @@ mpd_inotify_finish(void) g_list_free(directory->children); if (directory != &inotify_root) - g_slice_free(WatchDirectory, directory); + delete directory; } inotify_directories.clear(); -- cgit v1.2.3