db/DatabaseSong: DatabaseDetachSong(uri) returns instance, not pointer
This commit is contained in:
parent
7225e919fc
commit
d184231169
@ -41,7 +41,7 @@ SongLoader::LoadFromDatabase(const char *uri) const
|
|||||||
{
|
{
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
if (db != nullptr)
|
if (db != nullptr)
|
||||||
return DatabaseDetachSong(*db, *storage, uri);
|
return new DetachedSong(DatabaseDetachSong(*db, *storage, uri));
|
||||||
#else
|
#else
|
||||||
(void)uri;
|
(void)uri;
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,7 +41,7 @@ DatabaseDetachSong(const Storage &storage, const LightSong &song)
|
|||||||
return detached;
|
return detached;
|
||||||
}
|
}
|
||||||
|
|
||||||
DetachedSong *
|
DetachedSong
|
||||||
DatabaseDetachSong(const Database &db, const Storage &storage, const char *uri)
|
DatabaseDetachSong(const Database &db, const Storage &storage, const char *uri)
|
||||||
{
|
{
|
||||||
const LightSong *tmp = db.GetSong(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); };
|
AtScopeExit(&db, tmp) { db.ReturnSong(tmp); };
|
||||||
|
|
||||||
return new DetachedSong(DatabaseDetachSong(storage, *tmp));
|
return DatabaseDetachSong(storage, *tmp);
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,12 @@ DatabaseDetachSong(const Storage &storage, const LightSong &song);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Look up a song in the database and convert it to a #DetachedSong
|
* 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
|
gcc_pure
|
||||||
DetachedSong *
|
DetachedSong
|
||||||
DatabaseDetachSong(const Database &db, const Storage &storage,
|
DatabaseDetachSong(const Database &db, const Storage &storage,
|
||||||
const char *uri);
|
const char *uri);
|
||||||
|
|
||||||
|
@ -107,15 +107,15 @@ MakeTag2c()
|
|||||||
static const char *uri1 = "/foo/bar.ogg";
|
static const char *uri1 = "/foo/bar.ogg";
|
||||||
static const char *uri2 = "foo/bar.ogg";
|
static const char *uri2 = "foo/bar.ogg";
|
||||||
|
|
||||||
DetachedSong *
|
DetachedSong
|
||||||
DatabaseDetachSong(gcc_unused const Database &db,
|
DatabaseDetachSong(gcc_unused const Database &db,
|
||||||
gcc_unused const Storage &_storage,
|
gcc_unused const Storage &_storage,
|
||||||
const char *uri)
|
const char *uri)
|
||||||
{
|
{
|
||||||
if (strcmp(uri, uri2) == 0)
|
if (strcmp(uri, uri2) == 0)
|
||||||
return new DetachedSong(uri, MakeTag2a());
|
return DetachedSong(uri, MakeTag2a());
|
||||||
|
|
||||||
return nullptr;
|
throw std::runtime_error("No such song");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Loading…
Reference in New Issue
Block a user