Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
6d0ada7f
Commit
6d0ada7f
authored
Aug 05, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/lastfm: allocate the lastfm_playlist object at the end
Simplify the error path, because the other allocations may fail.
parent
af63372d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
LastFMPlaylistPlugin.cxx
src/playlist/LastFMPlaylistPlugin.cxx
+14
-15
No files found.
src/playlist/LastFMPlaylistPlugin.cxx
View file @
6d0ada7f
...
...
@@ -156,7 +156,6 @@ lastfm_find(const char *response, const char *name)
static
struct
playlist_provider
*
lastfm_open_uri
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
)
{
struct
lastfm_playlist
*
playlist
;
GError
*
error
=
NULL
;
char
*
p
,
*
q
,
*
response
,
*
session
;
...
...
@@ -209,11 +208,6 @@ lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond)
}
}
/* create the playlist object */
playlist
=
g_new
(
struct
lastfm_playlist
,
1
);
playlist_provider_init
(
&
playlist
->
base
,
&
lastfm_playlist_plugin
);
/* open the last.fm playlist */
p
=
g_strconcat
(
"http://ws.audioscrobbler.com/radio/xspf.php?"
...
...
@@ -221,40 +215,45 @@ lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond)
NULL
);
g_free
(
session
);
playlist
->
is
=
input_stream_open
(
p
,
mutex
,
cond
,
&
error
);
const
auto
is
=
input_stream_open
(
p
,
mutex
,
cond
,
&
error
);
g_free
(
p
);
if
(
playlist
->
is
==
NULL
)
{
if
(
is
==
nullptr
)
{
if
(
error
!=
NULL
)
{
g_warning
(
"Failed to load XSPF playlist: %s"
,
error
->
message
);
g_error_free
(
error
);
}
else
g_warning
(
"Failed to load XSPF playlist"
);
g_free
(
playlist
);
return
NULL
;
}
mutex
.
lock
();
input_stream_wait_ready
(
playlist
->
is
);
input_stream_wait_ready
(
is
);
/* last.fm does not send a MIME type, we have to fake it here
:-( */
input_stream_override_mime_type
(
playlist
->
is
,
"application/xspf+xml"
);
input_stream_override_mime_type
(
is
,
"application/xspf+xml"
);
mutex
.
unlock
();
/* parse the XSPF playlist */
playlist
->
xspf
=
playlist_list_open_stream
(
playlist
->
is
,
NULL
);
if
(
playlist
->
xspf
==
NULL
)
{
input_stream_close
(
playlist
->
is
);
g_free
(
playlist
);
const
auto
xspf
=
playlist_list_open_stream
(
is
,
nullptr
);
if
(
xspf
==
nullptr
)
{
input_stream_close
(
is
);
g_warning
(
"Failed to parse XSPF playlist"
);
return
NULL
;
}
/* create the playlist object */
const
auto
playlist
=
g_new
(
struct
lastfm_playlist
,
1
);
playlist_provider_init
(
&
playlist
->
base
,
&
lastfm_playlist_plugin
);
playlist
->
is
=
is
;
playlist
->
xspf
=
xspf
;
return
&
playlist
->
base
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment