aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-10-13 22:26:23 -0700
committerEric Wong <normalperson@yhbt.net>2008-10-13 22:26:23 -0700
commitc489ec9d8d3197227a63f507064ccadf0fe81e58 (patch)
treea4e1cd02026abfb25999a846b9b9765ac5325eef /src
parent0641819a0308dd1b0012450dfd5821946f6c3bdc (diff)
downloadmpd-eric.tar.gz
mpd-eric.tar.xz
mpd-eric.zip
Revert "directory: avoid magic in directory_walk"eric
This reverts commit 65688ec9e8841fb11c166d3e480dbada01d99746. That change introduced a new bug that I'm too sleepy to fix at the moment. I got too giddy after making e5c604feac962f654ba2cb7739ef33b9242cb072 that I immediately broke it differently again :) Perhaps I should start sleeping more than 3 hours a night...
Diffstat (limited to 'src')
-rw-r--r--src/directory.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/directory.c b/src/directory.c
index 70d7dafe0..fe9e83405 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -49,34 +49,24 @@ static int free_each_song(struct mpd_song *song, mpd_unused void *arg)
return 0;
}
-static int free_each_dir(struct directory *dir, void *arg)
-{
- if (dir != arg) {
- assert(dir != &music_root);
- assert(dir->parent);
- dirvec_delete(&dir->parent->children, dir);
- assert(!dir->songs.nr);
- assert(!dir->songs.base);
- assert(!dir->children.nr);
- assert(!dir->children.base);
- free(dir);
- }
- return 0;
-}
-
-void directory_free(struct directory *dir)
+static int free_each_dir(struct directory *dir, mpd_unused void *arg)
{
if (dir != &music_root) {
assert(dir->parent);
dirvec_delete(&dir->parent->children, dir);
}
- directory_walk(dir, free_each_song, free_each_dir, dir);
assert(!dir->songs.nr);
assert(!dir->songs.base);
assert(!dir->children.nr);
assert(!dir->children.base);
if (dir != &music_root)
free(dir);
+ return 0;
+}
+
+void directory_free(struct directory *dir)
+{
+ directory_walk(dir, free_each_song, free_each_dir, NULL);
}
static int dir_pruner(struct directory *dir, void *_dv)
@@ -145,8 +135,9 @@ int directory_walk(struct directory *dir,
{
int err = 0;
- if (forEachDir && (err = forEachDir(dir, data)) < 0)
- return err;
+ if (forEachDir && forEachDir != free_each_dir)
+ if ((err = forEachDir(dir, data)) < 0)
+ return err;
if (forEachSong) {
err = songvec_for_each(&dir->songs, forEachSong, data);
@@ -162,6 +153,8 @@ int directory_walk(struct directory *dir,
dw_arg.data = data;
err = dirvec_for_each(&dir->children, dirwalk_x, &dw_arg);
}
-
+ if (forEachDir == free_each_dir)
+ if ((err = forEachDir(dir, data)) < 0)
+ return err;
return err;
}