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
34f636ff
Commit
34f636ff
authored
May 12, 2021
by
GrimReaperFloof
Committed by
Max Kellermann
May 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change WritableBuffer<uint8_t> to AllocatedArray<std::byte>
parent
a134f692
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
19 deletions
+13
-19
ModCommon.cxx
src/decoder/plugins/ModCommon.cxx
+10
-14
ModCommon.hxx
src/decoder/plugins/ModCommon.hxx
+2
-2
ModplugDecoderPlugin.cxx
src/decoder/plugins/ModplugDecoderPlugin.cxx
+1
-3
No files found.
src/decoder/plugins/ModCommon.cxx
View file @
34f636ff
...
...
@@ -23,16 +23,16 @@
static
constexpr
size_t
MOD_PREALLOC_BLOCK
=
256
*
1024
;
static
constexpr
offset_type
MOD_FILE_LIMIT
=
100
*
1024
*
1024
;
WritableBuffer
<
uint8_t
>
AllocatedArray
<
std
::
byte
>
mod_loadfile
(
const
Domain
*
domain
,
DecoderClient
*
client
,
InputStream
&
is
)
{
//known/unknown size, preallocate array, lets read in chunks
const
bool
is_stream
=
!
is
.
KnownSize
();
size_t
buffer_size
;
WritableBuffer
<
uint8_t
>
buffer
;
if
(
is_stream
)
buffer
.
size
=
MOD_PREALLOC_BLOCK
;
if
(
is_stream
)
buffer_size
=
MOD_PREALLOC_BLOCK
;
else
{
const
auto
size
=
is
.
GetSize
();
...
...
@@ -46,13 +46,13 @@ mod_loadfile(const Domain *domain, DecoderClient *client, InputStream &is)
return
nullptr
;
}
buffer
.
size
=
size
;
buffer
_
size
=
size
;
}
buffer
.
data
=
new
uint8_t
[
buffer
.
size
]
;
auto
buffer
=
AllocatedArray
<
std
::
byte
>
(
buffer_size
)
;
uint8_t
*
const
end
=
buffer
.
end
();
uint8_t
*
p
=
buffer
.
begin
();
std
::
byte
*
const
end
=
buffer
.
end
();
std
::
byte
*
p
=
buffer
.
begin
();
while
(
true
)
{
size_t
ret
=
decoder_read
(
client
,
is
,
p
,
end
-
p
);
...
...
@@ -62,8 +62,6 @@ mod_loadfile(const Domain *domain, DecoderClient *client, InputStream &is)
break
;
/* I/O error - skip this song */
delete
[]
buffer
.
data
;
buffer
.
data
=
nullptr
;
return
buffer
;
}
...
...
@@ -73,13 +71,11 @@ mod_loadfile(const Domain *domain, DecoderClient *client, InputStream &is)
break
;
LogWarning
(
*
domain
,
"stream too large"
);
delete
[]
buffer
.
data
;
buffer
.
data
=
nullptr
;
return
buffer
;
}
}
buffer
.
size
=
p
-
buffer
.
data
;
buffer
.
SetSize
(
p
-
buffer
.
data
())
;
return
buffer
;
}
src/decoder/plugins/ModCommon.hxx
View file @
34f636ff
...
...
@@ -22,9 +22,9 @@
#include "../DecoderAPI.hxx"
#include "input/InputStream.hxx"
#include "util/
WritableBuffer
.hxx"
#include "util/
AllocatedArray
.hxx"
#include "util/Domain.hxx"
WritableBuffer
<
uint8_t
>
mod_loadfile
(
const
Domain
*
domain
,
DecoderClient
*
client
,
InputStream
&
is
);
AllocatedArray
<
std
::
byte
>
mod_loadfile
(
const
Domain
*
domain
,
DecoderClient
*
client
,
InputStream
&
is
);
#endif
src/decoder/plugins/ModplugDecoderPlugin.cxx
View file @
34f636ff
...
...
@@ -22,7 +22,6 @@
#include "../DecoderAPI.hxx"
#include "input/InputStream.hxx"
#include "tag/Handler.hxx"
#include "util/WritableBuffer.hxx"
#include "util/Domain.hxx"
#include "util/RuntimeError.hxx"
#include "util/StringView.hxx"
...
...
@@ -79,8 +78,7 @@ LoadModPlugFile(DecoderClient *client, InputStream &is)
return
nullptr
;
}
ModPlugFile
*
f
=
ModPlug_Load
(
buffer
.
data
,
buffer
.
size
);
delete
[]
buffer
.
data
;
ModPlugFile
*
f
=
ModPlug_Load
(
buffer
.
data
(),
buffer
.
size
());
return
f
;
}
...
...
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