diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-12 01:47:11 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-10-12 05:27:33 -0700 |
commit | a9f0147852c6dd4e355ac339fc4e3f2186cdb155 (patch) | |
tree | cb62786c70aab0574ec51ebe48e5709a26013e68 | |
parent | 6ad5891f2c57bca861d51160cbfa54f172fa1ea5 (diff) | |
download | mpd-a9f0147852c6dd4e355ac339fc4e3f2186cdb155.tar.gz mpd-a9f0147852c6dd4e355ac339fc4e3f2186cdb155.tar.xz mpd-a9f0147852c6dd4e355ac339fc4e3f2186cdb155.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | src/directory.c | 14 |
1 files changed, 14 insertions, 0 deletions
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) |