From a9f0147852c6dd4e355ac339fc4e3f2186cdb155 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 12 Oct 2008 01:47:11 -0700 Subject: directory: directory_free kills all that it contains Only call this in the main thread; it is NOT thread safe and not designed to be. --- src/directory.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/directory.c b/src/directory.c index 6a0bd18fd..709353476 100644 --- a/src/directory.c +++ b/src/directory.c @@ -42,8 +42,22 @@ struct directory * directory_new(const char *path, struct directory * parent) return dir; } +static int free_each_song(struct mpd_song *song, mpd_unused void *arg) +{ + song_free(song); + return 0; +} + +static int free_each_dir(struct directory *dir, void *arg) +{ + if (arg != dir) + directory_free(dir); + return 0; +} + void directory_free(struct directory *dir) { + directory_walk(dir, free_each_song, free_each_dir, dir); dirvec_destroy(&dir->children); songvec_destroy(&dir->songs); if (dir != &music_root) -- cgit v1.2.3