diff options
author | Max Kellermann <max@duempel.org> | 2008-10-07 22:10:42 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-07 22:10:42 +0200 |
commit | c47f97e1dc6a37459f90daf78a35c1751ea090e3 (patch) | |
tree | 099a0f87789f4b690b43d1b5fb6f4e3c086f4cd0 /src/song_save.c | |
parent | f0366cc8ca8c42063d18196fca757017a4390f88 (diff) | |
download | mpd-c47f97e1dc6a37459f90daf78a35c1751ea090e3.tar.gz mpd-c47f97e1dc6a37459f90daf78a35c1751ea090e3.tar.xz mpd-c47f97e1dc6a37459f90daf78a35c1751ea090e3.zip |
song: use songvec_for_each() in songvec_print() / songvec_save()
songvec_for_each() has locking, use it instead of manually iterating
over the songvec items.
Diffstat (limited to 'src/song_save.c')
-rw-r--r-- | src/song_save.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/song_save.c b/src/song_save.c index 4c40a262c..c29ee86a8 100644 --- a/src/song_save.c +++ b/src/song_save.c @@ -37,28 +37,27 @@ static void song_save_url(FILE *fp, Song * song) song->url); } -static void song_save(FILE *fp, Song * song) +static int +song_save(Song *song, void *data) { + FILE *fp = data; + + fprintf(fp, SONG_KEY "%s\n", song->url); + song_save_url(fp, song); if (song->tag != NULL) tag_save(fp, song->tag); + + fprintf(fp, SONG_MTIME "%li\n", (long)song->mtime); + + return 0; } void songvec_save(FILE *fp, struct songvec *sv) { - int i; - Song **sp = sv->base; - fprintf(fp, "%s\n", SONG_BEGIN); - - for (i = sv->nr; --i >= 0; ) { - Song *song = *sp++; - fprintf(fp, "%s%s\n", SONG_KEY, song->url); - song_save(fp, song); - fprintf(fp, "%s%li\n", SONG_MTIME, (long)song->mtime); - } - + songvec_for_each(sv, song_save, fp); fprintf(fp, "%s\n", SONG_END); } |