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
75582d47
Commit
75582d47
authored
Nov 26, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SongSave: wrap DetachedSong* in std::unique_ptr
parent
28fdf1e9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
15 deletions
+9
-15
SongSave.cxx
src/SongSave.cxx
+2
-6
SongSave.hxx
src/SongSave.hxx
+3
-1
DirectorySave.cxx
src/db/plugins/simple/DirectorySave.cxx
+1
-2
QueueSave.cxx
src/queue/QueueSave.cxx
+3
-6
No files found.
src/SongSave.cxx
View file @
75582d47
...
...
@@ -76,10 +76,10 @@ song_save(BufferedOutputStream &os, const DetachedSong &song)
os
.
Format
(
SONG_END
"
\n
"
);
}
DetachedSong
*
std
::
unique_ptr
<
DetachedSong
>
song_load
(
TextFile
&
file
,
const
char
*
uri
)
{
DetachedSong
*
song
=
new
DetachedSong
(
uri
);
auto
song
=
std
::
make_unique
<
DetachedSong
>
(
uri
);
TagBuilder
tag
;
...
...
@@ -88,8 +88,6 @@ song_load(TextFile &file, const char *uri)
strcmp
(
line
,
SONG_END
)
!=
0
)
{
char
*
colon
=
strchr
(
line
,
':'
);
if
(
colon
==
nullptr
||
colon
==
line
)
{
delete
song
;
throw
FormatRuntimeError
(
"unknown line in db: %s"
,
line
);
}
...
...
@@ -116,8 +114,6 @@ song_load(TextFile &file, const char *uri)
song
->
SetStartTime
(
SongTime
::
FromMS
(
start_ms
));
song
->
SetEndTime
(
SongTime
::
FromMS
(
end_ms
));
}
else
{
delete
song
;
throw
FormatRuntimeError
(
"unknown line in db: %s"
,
line
);
}
}
...
...
src/SongSave.hxx
View file @
75582d47
...
...
@@ -20,6 +20,8 @@
#ifndef MPD_SONG_SAVE_HXX
#define MPD_SONG_SAVE_HXX
#include <memory>
#define SONG_BEGIN "song_begin: "
struct
Song
;
...
...
@@ -39,7 +41,7 @@ song_save(BufferedOutputStream &os, const DetachedSong &song);
*
* Throws #std::runtime_error on error.
*/
DetachedSong
*
std
::
unique_ptr
<
DetachedSong
>
song_load
(
TextFile
&
file
,
const
char
*
uri
);
#endif
src/db/plugins/simple/DirectorySave.cxx
View file @
75582d47
...
...
@@ -160,11 +160,10 @@ directory_load(TextFile &file, Directory &directory)
if
(
directory
.
FindSong
(
name
)
!=
nullptr
)
throw
FormatRuntimeError
(
"Duplicate song '%s'"
,
name
);
DetachedSong
*
song
=
song_load
(
file
,
name
);
auto
song
=
song_load
(
file
,
name
);
directory
.
AddSong
(
Song
::
NewFrom
(
std
::
move
(
*
song
),
directory
));
delete
song
;
}
else
if
((
p
=
StringAfterPrefix
(
line
,
PLAYLIST_META_BEGIN
)))
{
const
char
*
name
=
p
;
playlist_metadata_load
(
file
,
directory
.
playlists
,
name
);
...
...
src/queue/QueueSave.cxx
View file @
75582d47
...
...
@@ -89,7 +89,7 @@ queue_load_song(TextFile &file, const SongLoader &loader,
return
;
}
DetachedSong
*
song
;
std
::
unique_ptr
<
DetachedSong
>
song
;
if
((
p
=
StringAfterPrefix
(
line
,
SONG_BEGIN
)))
{
const
char
*
uri
=
p
;
...
...
@@ -111,14 +111,11 @@ queue_load_song(TextFile &file, const SongLoader &loader,
const
char
*
uri
=
endptr
+
1
;
song
=
new
DetachedSong
(
uri
);
song
=
std
::
make_unique
<
DetachedSong
>
(
uri
);
}
if
(
!
playlist_check_translate_song
(
*
song
,
nullptr
,
loader
))
{
delete
song
;
if
(
playlist_check_translate_song
(
*
song
,
nullptr
,
loader
))
return
;
}
queue
.
Append
(
std
::
move
(
*
song
),
priority
);
delete
song
;
}
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