update: free deleted subdirectories

Use delete_directory() for removing sub directories instead of
dirvec_clear().  This ensures that all memory occupied by
subdirectories of deleted directories is freed.
This commit is contained in:
Max Kellermann 2009-02-12 19:11:26 +01:00
parent 16bab6019b
commit df9245c2aa
2 changed files with 7 additions and 2 deletions

1
NEWS
View File

@ -61,6 +61,7 @@ ver 0.14.2 (2009/??/??)
* mapper: remove trailing slashes from music_directory
* player: set player error when output device fails
* update: recursively purge deleted directories
* update: free deleted subdirectories
ver 0.14.1 (2009/01/17)

View File

@ -132,6 +132,9 @@ delete_each_song(struct song *song, G_GNUC_UNUSED void *data)
return 0;
}
static void
delete_directory(struct directory *directory);
/**
* Recursively remove all sub directories and songs from a directory,
* leaving an empty directory.
@ -142,8 +145,9 @@ clear_directory(struct directory *directory)
int i;
for (i = directory->children.nr; --i >= 0;)
clear_directory(directory->children.base[i]);
dirvec_clear(&directory->children);
delete_directory(directory->children.base[i]);
assert(directory->children.nr == 0);
songvec_for_each(&directory->songs, delete_each_song, directory);
}