use auto with make_unique
C arrays can be used with make_unique in C++17. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
061dd2dfef
commit
31aa6d0c4f
@ -213,7 +213,7 @@ read_stream_art(Response &r, const std::string_view art_directory,
|
||||
std::min<offset_type>(art_file_size - offset,
|
||||
r.GetClient().binary_limit);
|
||||
|
||||
std::unique_ptr<std::byte[]> buffer(new std::byte[buffer_size]);
|
||||
auto buffer = std::make_unique<std::byte[]>(buffer_size);
|
||||
|
||||
std::size_t read_size = 0;
|
||||
if (buffer_size > 0) {
|
||||
|
@ -310,7 +310,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag *mpd_tag) noexcept
|
||||
id3_data = stream.this_frame;
|
||||
mad_stream_skip(&(stream), tagsize);
|
||||
} else {
|
||||
allocated.reset(new id3_byte_t[tagsize]);
|
||||
allocated = std::make_unique<id3_byte_t[]>(tagsize);
|
||||
memcpy(allocated.get(), stream.this_frame, count);
|
||||
mad_stream_skip(&(stream), count);
|
||||
|
||||
|
@ -137,7 +137,7 @@ SidplayGlobal::SidplayGlobal(const ConfigBlock &block)
|
||||
const auto kernal_path = block.GetPath("kernal");
|
||||
if (!kernal_path.IsNull())
|
||||
{
|
||||
kernal.reset(new uint8_t[rom_size]);
|
||||
kernal = std::make_unique<uint8_t[]>(rom_size);
|
||||
loadRom(kernal_path, kernal.get());
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ SidplayGlobal::SidplayGlobal(const ConfigBlock &block)
|
||||
const auto basic_path = block.GetPath("basic");
|
||||
if (!basic_path.IsNull())
|
||||
{
|
||||
basic.reset(new uint8_t[rom_size]);
|
||||
basic = std::make_unique<uint8_t[]>(rom_size);
|
||||
loadRom(basic_path, basic.get());
|
||||
}
|
||||
#endif
|
||||
|
@ -54,7 +54,7 @@ UCharToUTF8(std::basic_string_view<UChar> src)
|
||||
/* worst-case estimate */
|
||||
size_t dest_capacity = 4 * src.size();
|
||||
|
||||
std::unique_ptr<char[]> dest(new char[dest_capacity + 1]);
|
||||
auto dest = std::make_unique<char[]>(dest_capacity + 1);
|
||||
|
||||
UErrorCode error_code = U_ZERO_ERROR;
|
||||
int32_t dest_length;
|
||||
|
@ -36,8 +36,7 @@ ScanVorbisPicture(StringView value, TagHandler &handler) noexcept
|
||||
return;
|
||||
|
||||
size_t debase64_size = CalculateBase64OutputSize(value.size);
|
||||
std::unique_ptr<uint8_t[]> debase64_buffer;
|
||||
debase64_buffer.reset(new uint8_t[debase64_size]);
|
||||
auto debase64_buffer = std::make_unique<uint8_t[]>(debase64_size);
|
||||
|
||||
try {
|
||||
debase64_size =
|
||||
|
@ -291,7 +291,7 @@ osx_output_set_channel_map(OSXOutput *oo)
|
||||
OSStatus status;
|
||||
|
||||
const UInt32 num_channels = AudioUnitGetChannelsPerFrame(oo->au);
|
||||
std::unique_ptr<SInt32[]> channel_map(new SInt32[num_channels]);
|
||||
auto channel_map = std::make_unique<SInt32[]>(num_channels);
|
||||
osx_output_parse_channel_map(oo->device_name,
|
||||
oo->channel_map,
|
||||
channel_map.get(),
|
||||
|
@ -66,7 +66,7 @@ try {
|
||||
remaining -= sizeof(footer);
|
||||
assert(remaining > 10);
|
||||
|
||||
std::unique_ptr<char[]> buffer(new char[remaining]);
|
||||
auto buffer = std::make_unique<char[]>(remaining);
|
||||
is.ReadFull(lock, buffer.get(), remaining);
|
||||
|
||||
/* read tags */
|
||||
|
@ -63,7 +63,7 @@ try {
|
||||
/* we have enough data already */
|
||||
return UniqueId3Tag(id3_tag_parse(query_buffer, tag_size));
|
||||
|
||||
std::unique_ptr<id3_byte_t[]> tag_buffer(new id3_byte_t[tag_size]);
|
||||
auto tag_buffer = std::make_unique<id3_byte_t[]>(tag_size);
|
||||
|
||||
/* copy the start of the tag we already have to the allocated
|
||||
buffer */
|
||||
@ -198,7 +198,7 @@ try {
|
||||
/* too large, don't allocate so much memory */
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<id3_byte_t[]> buffer(new id3_byte_t[size]);
|
||||
auto buffer = std::make_unique<id3_byte_t[]>(size);
|
||||
is.ReadFull(lock, buffer.get(), size);
|
||||
|
||||
return UniqueId3Tag(id3_tag_parse(buffer.get(), size));
|
||||
|
Loading…
Reference in New Issue
Block a user