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
a7976cd0
Commit
a7976cd0
authored
Aug 10, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/sidplay: automatic memory management inside struct SidplayGlobal
parent
bed8a0e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
19 deletions
+12
-19
SidplayDecoderPlugin.cxx
src/decoder/plugins/SidplayDecoderPlugin.cxx
+12
-19
No files found.
src/decoder/plugins/SidplayDecoderPlugin.cxx
View file @
a7976cd0
...
...
@@ -56,6 +56,7 @@
#endif
#include <iterator>
#include <memory>
#include <string.h>
#include <stdio.h>
...
...
@@ -69,7 +70,7 @@
static
constexpr
Domain
sidplay_domain
(
"sidplay"
);
struct
SidplayGlobal
{
SidDatabase
*
songlength_database
;
std
::
unique_ptr
<
SidDatabase
>
songlength_database
;
bool
all_files_are_containers
;
unsigned
default_songlength
;
...
...
@@ -78,19 +79,10 @@ struct SidplayGlobal {
bool
filter_setting
;
#ifdef HAVE_SIDPLAYFP
uint8_t
*
kernal
=
nullptr
,
*
basic
=
nullptr
;
std
::
unique_ptr
<
uint8_t
[]
>
kernal
,
basic
;
#endif
explicit
SidplayGlobal
(
const
ConfigBlock
&
block
);
~
SidplayGlobal
()
noexcept
{
delete
songlength_database
;
#ifdef HAVE_SIDPLAYFP
delete
[]
basic
;
delete
[]
kernal
;
#endif
}
};
static
SidplayGlobal
*
sidplay_global
;
...
...
@@ -109,10 +101,10 @@ static void loadRom(const Path rom_path, uint8_t *dump)
}
#endif
static
SidDatabase
*
static
std
::
unique_ptr
<
SidDatabase
>
sidplay_load_songlength_db
(
const
Path
path
)
noexcept
{
SidDatabase
*
db
=
new
SidDatabase
();
auto
db
=
std
::
make_unique
<
SidDatabase
>
();
#ifdef HAVE_SIDPLAYFP
bool
error
=
!
db
->
open
(
path
.
c_str
());
#else
...
...
@@ -122,7 +114,6 @@ sidplay_load_songlength_db(const Path path) noexcept
FormatError
(
sidplay_domain
,
"unable to read songlengths file %s: %s"
,
path
.
c_str
(),
db
->
error
());
delete
db
;
return
nullptr
;
}
...
...
@@ -151,16 +142,16 @@ SidplayGlobal::SidplayGlobal(const ConfigBlock &block)
const
auto
kernal_path
=
block
.
GetPath
(
"kernal"
);
if
(
!
kernal_path
.
IsNull
())
{
kernal
=
new
uint8_t
[
rom_size
]
;
loadRom
(
kernal_path
,
kernal
);
kernal
.
reset
(
new
uint8_t
[
rom_size
])
;
loadRom
(
kernal_path
,
kernal
.
get
()
);
}
/* read basic rom dump file */
const
auto
basic_path
=
block
.
GetPath
(
"basic"
);
if
(
!
basic_path
.
IsNull
())
{
basic
=
new
uint8_t
[
rom_size
]
;
loadRom
(
basic_path
,
basic
);
basic
.
reset
(
new
uint8_t
[
rom_size
])
;
loadRom
(
basic_path
,
basic
.
get
()
);
}
#endif
}
...
...
@@ -272,7 +263,9 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
#ifdef HAVE_SIDPLAYFP
sidplayfp
player
;
player
.
setRoms
(
sidplay_global
->
kernal
,
sidplay_global
->
basic
,
nullptr
);
player
.
setRoms
(
sidplay_global
->
kernal
.
get
(),
sidplay_global
->
basic
.
get
(),
nullptr
);
#else
sidplay2
player
;
#endif
...
...
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