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
ebc006ab
Commit
ebc006ab
authored
Jul 06, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/simple: wrap LightSong in Manual<>
Prepare to make LightSong non-assignable.
parent
86a02871
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
SimpleDatabasePlugin.cxx
src/db/plugins/simple/SimpleDatabasePlugin.cxx
+10
-8
SimpleDatabasePlugin.hxx
src/db/plugins/simple/SimpleDatabasePlugin.hxx
+2
-1
No files found.
src/db/plugins/simple/SimpleDatabasePlugin.cxx
View file @
ebc006ab
...
...
@@ -237,30 +237,32 @@ SimpleDatabase::GetSong(const char *uri) const
throw
DatabaseError
(
DatabaseErrorCode
::
NOT_FOUND
,
"No such song"
);
light_song
=
song
->
Export
(
);
light_song
.
Construct
(
song
->
Export
()
);
#ifndef NDEBUG
++
borrowed_song_count
;
#endif
return
&
light_song
;
return
&
light_song
.
Get
()
;
}
void
SimpleDatabase
::
ReturnSong
(
gcc_unused
const
LightSong
*
song
)
const
{
assert
(
song
!=
nullptr
);
assert
(
song
==
&
light_song
||
song
==
prefixed_light_song
);
delete
prefixed_light_song
;
prefixed_light_song
=
nullptr
;
assert
(
song
==
&
light_song
.
Get
()
||
song
==
prefixed_light_song
);
if
(
prefixed_light_song
!=
nullptr
)
{
delete
prefixed_light_song
;
prefixed_light_song
=
nullptr
;
}
else
{
#ifndef NDEBUG
if
(
song
==
&
light_song
)
{
assert
(
borrowed_song_count
>
0
);
--
borrowed_song_count
;
}
#endif
light_song
.
Destruct
();
}
}
void
...
...
src/db/plugins/simple/SimpleDatabasePlugin.hxx
View file @
ebc006ab
...
...
@@ -24,6 +24,7 @@
#include "db/Interface.hxx"
#include "fs/AllocatedPath.hxx"
#include "db/LightSong.hxx"
#include "util/Manual.hxx"
#include "Compiler.h"
#include <cassert>
...
...
@@ -61,7 +62,7 @@ class SimpleDatabase : public Database {
/**
* A buffer for GetSong().
*/
mutable
LightSong
light_song
;
mutable
Manual
<
LightSong
>
light_song
;
#ifndef NDEBUG
mutable
unsigned
borrowed_song_count
;
...
...
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