aboutsummaryrefslogtreecommitdiff
path: root/src/playlist.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-01-01 10:09:31 +0000
committerEric Wong <normalperson@yhbt.net>2008-01-01 10:09:31 +0000
commit09936358fa8098444019fc2a470b1685af1a19de (patch)
tree8dbb397c7c6f5ad77ebc5becd3f5307889691af8 /src/playlist.c
parent390ed29740c4aa5caf41d659bf392b20aec4788f (diff)
storedPlaylist: cleanup API and avoid needless heap allocations + error checks
git-svn-id: https://svn.musicpd.org/mpd/trunk@7119 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/playlist.c')
-rw-r--r--src/playlist.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 6c2d014c..3087fd44 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -1516,11 +1516,12 @@ int getPlaylistSongId(int song)
int PlaylistInfo(int fd, char *utf8file, int detail)
{
ListNode *node;
- StoredPlaylist *sp = loadStoredPlaylist(utf8file, fd);
- if (sp == NULL)
+ StoredPlaylist sp;
+
+ if (loadStoredPlaylist(fd, &sp, utf8file) < 0)
return -1;
- node = sp->list->firstNode;
+ node = sp.list->firstNode;
while (node != NULL) {
char *temp = node->data;
int wrote = 0;
@@ -1540,18 +1541,19 @@ int PlaylistInfo(int fd, char *utf8file, int detail)
node = node->nextNode;
}
- freeStoredPlaylist(sp);
+ freeStoredPlaylist(&sp);
return 0;
}
int loadPlaylist(int fd, char *utf8file)
{
ListNode *node;
- StoredPlaylist *sp = loadStoredPlaylist(utf8file, fd);
- if (sp == NULL)
+ StoredPlaylist sp;
+
+ if (loadStoredPlaylist(fd, &sp, utf8file) < 0)
return -1;
- node = sp->list->firstNode;
+ node = sp.list->firstNode;
while (node != NULL) {
char *temp = node->data;
if ((addToPlaylist(STDERR_FILENO, temp, 0)) < 0) {
@@ -1573,7 +1575,7 @@ int loadPlaylist(int fd, char *utf8file)
node = node->nextNode;
}
- freeStoredPlaylist(sp);
+ freeStoredPlaylist(&sp);
return 0;
}