aboutsummaryrefslogtreecommitdiffstats
path: root/src/update_walk.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-01-24 21:33:09 +0100
committerMax Kellermann <max@duempel.org>2012-01-24 22:26:43 +0100
commit84ba14fa294f43b5dc75f899533d0596031aabd6 (patch)
tree151a64e2e827f6f07791dd5642b88bab5d421dc8 /src/update_walk.c
parent3c75963352734dc33a0d6c833e9d5e1493d0e0d9 (diff)
downloadmpd-84ba14fa294f43b5dc75f899533d0596031aabd6.tar.gz
mpd-84ba14fa294f43b5dc75f899533d0596031aabd6.tar.xz
mpd-84ba14fa294f43b5dc75f899533d0596031aabd6.zip
directory: replace songvec with doubly linked list
Diffstat (limited to 'src/update_walk.c')
-rw-r--r--src/update_walk.c75
1 files changed, 28 insertions, 47 deletions
diff --git a/src/update_walk.c b/src/update_walk.c
index 728e5bb04..e5eedc025 100644
--- a/src/update_walk.c
+++ b/src/update_walk.c
@@ -92,6 +92,8 @@ directory_set_stat(struct directory *dir, const struct stat *st)
static void
delete_song(struct directory *dir, struct song *del)
{
+ assert(del->parent == dir);
+
/* first, prevent traversers in main task from getting this */
directory_remove_song(dir, del);
@@ -102,15 +104,6 @@ delete_song(struct directory *dir, struct song *del)
song_free(del);
}
-static int
-delete_each_song(struct song *song, G_GNUC_UNUSED void *data)
-{
- struct directory *directory = data;
- assert(song->parent == directory);
- delete_song(directory, song);
- return 0;
-}
-
static void
delete_directory(struct directory *directory);
@@ -125,7 +118,11 @@ clear_directory(struct directory *directory)
directory_for_each_child_safe(child, n, directory)
delete_directory(child);
- songvec_for_each(&directory->songs, delete_each_song, directory);
+ struct song *song, *ns;
+ directory_for_each_song_safe(song, ns, directory) {
+ assert(song->parent == directory);
+ delete_song(directory, song);
+ }
}
/**
@@ -159,25 +156,6 @@ delete_name_in(struct directory *parent, const char *name)
playlist_vector_remove(&parent->playlists, name);
}
-/* passed to songvec_for_each */
-static int
-delete_song_if_excluded(struct song *song, void *_data)
-{
- GSList *exclude_list = _data;
- char *name_fs;
-
- assert(song->parent != NULL);
-
- name_fs = utf8_to_fs_charset(song->uri);
- if (exclude_list_check(exclude_list, name_fs)) {
- delete_song(song->parent, song);
- modified = true;
- }
-
- g_free(name_fs);
- return 0;
-}
-
static void
remove_excluded_from_directory(struct directory *directory,
GSList *exclude_list)
@@ -194,26 +172,18 @@ remove_excluded_from_directory(struct directory *directory,
g_free(name_fs);
}
- songvec_for_each(&directory->songs,
- delete_song_if_excluded, exclude_list);
-}
+ struct song *song, *ns;
+ directory_for_each_song_safe(song, ns, directory) {
+ assert(song->parent == directory);
-/* passed to songvec_for_each */
-static int
-delete_song_if_removed(struct song *song, void *_data)
-{
- struct directory *dir = _data;
- char *path;
- struct stat st;
+ char *name_fs = utf8_to_fs_charset(song->uri);
+ if (exclude_list_check(exclude_list, name_fs)) {
+ delete_song(directory, song);
+ modified = true;
+ }
- if ((path = map_song_fs(song)) == NULL ||
- stat(path, &st) < 0 || !S_ISREG(st.st_mode)) {
- delete_song(dir, song);
- modified = true;
+ g_free(name_fs);
}
-
- g_free(path);
- return 0;
}
static bool
@@ -266,7 +236,18 @@ removeDeletedFromDirectory(struct directory *directory)
modified = true;
}
- songvec_for_each(&directory->songs, delete_song_if_removed, directory);
+ struct song *song, *ns;
+ directory_for_each_song_safe(song, ns, directory) {
+ char *path;
+ struct stat st;
+ if ((path = map_song_fs(song)) == NULL ||
+ stat(path, &st) < 0 || !S_ISREG(st.st_mode)) {
+ delete_song(directory, song);
+ modified = true;
+ }
+
+ g_free(path);
+ }
for (const struct playlist_metadata *pm = directory->playlists.head;
pm != NULL;) {