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
fcf0f829
Commit
fcf0f829
authored
Aug 15, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ProxyDatabasePlugin: add OO wrapper for mpd_entity
Let the C++ compiler take care for freeing the objects safely.
parent
0ed71fa0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
11 deletions
+32
-11
ProxyDatabasePlugin.cxx
src/db/ProxyDatabasePlugin.cxx
+32
-11
No files found.
src/db/ProxyDatabasePlugin.cxx
View file @
fcf0f829
...
...
@@ -267,13 +267,39 @@ Visit(struct directory &parent, const struct mpd_playlist *playlist,
return
success
;
}
static
std
::
list
<
struct
mpd_entity
*>
class
ProxyEntity
{
struct
mpd_entity
*
entity
;
public
:
explicit
ProxyEntity
(
struct
mpd_entity
*
_entity
)
:
entity
(
_entity
)
{}
ProxyEntity
(
const
ProxyEntity
&
other
)
=
delete
;
ProxyEntity
(
ProxyEntity
&&
other
)
:
entity
(
other
.
entity
)
{
other
.
entity
=
nullptr
;
}
~
ProxyEntity
()
{
if
(
entity
!=
nullptr
)
mpd_entity_free
(
entity
);
}
ProxyEntity
&
operator
=
(
const
ProxyEntity
&
other
)
=
delete
;
operator
const
struct
mpd_entity
*
()
const
{
return
entity
;
}
};
static
std
::
list
<
ProxyEntity
>
ReceiveEntities
(
struct
mpd_connection
*
connection
)
{
std
::
list
<
struct
mpd_entity
*
>
entities
;
std
::
list
<
ProxyEntity
>
entities
;
struct
mpd_entity
*
entity
;
while
((
entity
=
mpd_recv_entity
(
connection
))
!=
NULL
)
entities
.
push_back
(
entity
);
entities
.
push_back
(
ProxyEntity
(
entity
)
);
mpd_response_finish
(
connection
);
return
entities
;
...
...
@@ -287,14 +313,11 @@ Visit(struct mpd_connection *connection, struct directory &parent,
if
(
!
mpd_send_list_meta
(
connection
,
directory_get_path
(
&
parent
)))
return
CheckError
(
connection
,
error_r
);
std
::
list
<
struct
mpd_entity
*>
entities
=
ReceiveEntities
(
connection
);
if
(
!
CheckError
(
connection
,
error_r
))
{
for
(
auto
entity
:
entities
)
mpd_entity_free
(
entity
);
std
::
list
<
ProxyEntity
>
entities
(
ReceiveEntities
(
connection
));
if
(
!
CheckError
(
connection
,
error_r
))
return
false
;
}
for
(
auto
entity
:
entities
)
{
for
(
const
auto
&
entity
:
entities
)
{
switch
(
mpd_entity_get_type
(
entity
))
{
case
MPD_ENTITY_TYPE_UNKNOWN
:
break
;
...
...
@@ -316,8 +339,6 @@ Visit(struct mpd_connection *connection, struct directory &parent,
visit_playlist
,
error_r
);
break
;
}
mpd_entity_free
(
entity
);
}
return
CheckError
(
connection
,
error_r
);
...
...
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