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
1f90e3ce
Commit
1f90e3ce
authored
Jan 14, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/extm3u: allocate Tag instance on the stack
Automate the life cycle, making the code safer.
parent
676d8bb6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
ExtM3uPlaylistPlugin.cxx
src/playlist/ExtM3uPlaylistPlugin.cxx
+7
-12
No files found.
src/playlist/ExtM3uPlaylistPlugin.cxx
View file @
1f90e3ce
...
...
@@ -67,7 +67,7 @@ extm3u_open_stream(InputStream &is)
*
* @param line the rest of the input line after the colon
*/
static
Tag
*
static
Tag
extm3u_parse_tag
(
const
char
*
line
)
{
long
duration
;
...
...
@@ -77,7 +77,7 @@ extm3u_parse_tag(const char *line)
duration
=
strtol
(
line
,
&
endptr
,
10
);
if
(
endptr
[
0
]
!=
','
)
/* malformed line */
return
NULL
;
return
Tag
()
;
if
(
duration
<
0
)
/* 0 means unknown duration */
...
...
@@ -87,7 +87,7 @@ extm3u_parse_tag(const char *line)
if
(
*
name
==
0
&&
duration
==
0
)
/* no information available; don't allocate a tag
object */
return
NULL
;
return
Tag
()
;
TagBuilder
tag
;
tag
.
SetTime
(
duration
);
...
...
@@ -98,26 +98,23 @@ extm3u_parse_tag(const char *line)
if
(
*
name
!=
0
)
tag
.
AddItem
(
TAG_NAME
,
name
);
return
tag
.
Commit
New
();
return
tag
.
Commit
();
}
DetachedSong
*
ExtM3uPlaylist
::
NextSong
()
{
Tag
*
tag
=
NULL
;
Tag
tag
;
std
::
string
line
;
const
char
*
line_s
;
do
{
if
(
!
tis
.
ReadLine
(
line
))
{
delete
tag
;
if
(
!
tis
.
ReadLine
(
line
))
return
NULL
;
}
line_s
=
line
.
c_str
();
if
(
StringStartsWith
(
line_s
,
"#EXTINF:"
))
{
delete
tag
;
tag
=
extm3u_parse_tag
(
line_s
+
8
);
continue
;
}
...
...
@@ -125,9 +122,7 @@ ExtM3uPlaylist::NextSong()
line_s
=
strchug_fast
(
line_s
);
}
while
(
line_s
[
0
]
==
'#'
||
*
line_s
==
0
);
DetachedSong
*
song
=
new
DetachedSong
(
line_s
,
std
::
move
(
*
tag
));
delete
tag
;
return
song
;
return
new
DetachedSong
(
line_s
,
std
::
move
(
tag
));
}
static
const
char
*
const
extm3u_suffixes
[]
=
{
...
...
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