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.
This commit is contained in:
parent
ea515494cb
commit
8f9d9cc042
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "directory.h"
|
#include "directory.h"
|
||||||
|
#include "song.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
@ -44,6 +45,12 @@ directory_new(const char *path, struct directory *parent)
|
|||||||
void
|
void
|
||||||
directory_free(struct directory *directory)
|
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);
|
dirvec_destroy(&directory->children);
|
||||||
songvec_destroy(&directory->songs);
|
songvec_destroy(&directory->songs);
|
||||||
free(directory);
|
free(directory);
|
||||||
|
Loading…
Reference in New Issue
Block a user