aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-31 09:20:02 +0100
committerMax Kellermann <max@duempel.org>2008-10-31 09:20:02 +0100
commit8f9d9cc04233bffa23ab3dc071b4a3f256b31399 (patch)
tree9930d2789a7d5c17cab136f9453a96e97629dd08 /src
parentea515494cb23160c2eb05835411b8927a025026f (diff)
downloadmpd-8f9d9cc04233bffa23ab3dc071b4a3f256b31399.tar.gz
mpd-8f9d9cc04233bffa23ab3dc071b4a3f256b31399.tar.xz
mpd-8f9d9cc04233bffa23ab3dc071b4a3f256b31399.zip
directory: directory_free() frees children
directory_free() should free all of its children (subdirectories and songs). This way, db_finish() properly frees all allocated memory.
Diffstat (limited to 'src')
-rw-r--r--src/directory.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/directory.c b/src/directory.c
index ba1ae8560..ccf2be7a4 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -17,6 +17,7 @@
*/
#include "directory.h"
+#include "song.h"
#include "utils.h"
#include "path.h"
@@ -44,6 +45,12 @@ directory_new(const char *path, struct directory *parent)
void
directory_free(struct directory *directory)
{
+ for (unsigned i = 0; i < directory->songs.nr; ++i)
+ song_free(directory->songs.base[i]);
+
+ for (unsigned i = 0; i < directory->children.nr; ++i)
+ directory_free(directory->children.base[i]);
+
dirvec_destroy(&directory->children);
songvec_destroy(&directory->songs);
free(directory);