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
d1842311
Commit
d1842311
authored
Feb 08, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/DatabaseSong: DatabaseDetachSong(uri) returns instance, not pointer
parent
7225e919
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
10 deletions
+10
-10
SongLoader.cxx
src/SongLoader.cxx
+1
-1
DatabaseSong.cxx
src/db/DatabaseSong.cxx
+2
-2
DatabaseSong.hxx
src/db/DatabaseSong.hxx
+4
-4
test_translate_song.cxx
test/test_translate_song.cxx
+3
-3
No files found.
src/SongLoader.cxx
View file @
d1842311
...
...
@@ -41,7 +41,7 @@ SongLoader::LoadFromDatabase(const char *uri) const
{
#ifdef ENABLE_DATABASE
if
(
db
!=
nullptr
)
return
DatabaseDetachSong
(
*
db
,
*
storage
,
uri
);
return
new
DetachedSong
(
DatabaseDetachSong
(
*
db
,
*
storage
,
uri
)
);
#else
(
void
)
uri
;
#endif
...
...
src/db/DatabaseSong.cxx
View file @
d1842311
...
...
@@ -41,7 +41,7 @@ DatabaseDetachSong(const Storage &storage, const LightSong &song)
return
detached
;
}
DetachedSong
*
DetachedSong
DatabaseDetachSong
(
const
Database
&
db
,
const
Storage
&
storage
,
const
char
*
uri
)
{
const
LightSong
*
tmp
=
db
.
GetSong
(
uri
);
...
...
@@ -49,5 +49,5 @@ DatabaseDetachSong(const Database &db, const Storage &storage, const char *uri)
AtScopeExit
(
&
db
,
tmp
)
{
db
.
ReturnSong
(
tmp
);
};
return
new
DetachedSong
(
DatabaseDetachSong
(
storage
,
*
tmp
)
);
return
DatabaseDetachSong
(
storage
,
*
tmp
);
}
src/db/DatabaseSong.hxx
View file @
d1842311
...
...
@@ -37,12 +37,12 @@ DatabaseDetachSong(const Storage &storage, const LightSong &song);
/**
* Look up a song in the database and convert it to a #DetachedSong
* instance.
The caller is responsible for freeing it.
* instance.
*
*
@return nullptr on error
*
Throws std::runtime_error on error.
*/
gcc_
malloc
gcc_nonnull_all
DetachedSong
*
gcc_
pure
DetachedSong
DatabaseDetachSong
(
const
Database
&
db
,
const
Storage
&
storage
,
const
char
*
uri
);
...
...
test/test_translate_song.cxx
View file @
d1842311
...
...
@@ -107,15 +107,15 @@ MakeTag2c()
static
const
char
*
uri1
=
"/foo/bar.ogg"
;
static
const
char
*
uri2
=
"foo/bar.ogg"
;
DetachedSong
*
DetachedSong
DatabaseDetachSong
(
gcc_unused
const
Database
&
db
,
gcc_unused
const
Storage
&
_storage
,
const
char
*
uri
)
{
if
(
strcmp
(
uri
,
uri2
)
==
0
)
return
new
DetachedSong
(
uri
,
MakeTag2a
());
return
DetachedSong
(
uri
,
MakeTag2a
());
return
nullptr
;
throw
std
::
runtime_error
(
"No such song"
)
;
}
bool
...
...
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