From 4c0581ca5edb8ed884200c2b7b7cab1663d84ca0 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 18 Apr 2021 14:56:49 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20C++17:=20Use=20std::make=5Funiqu?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/dvlnet/abstract_net.cpp | 8 ++++---- Source/dvlnet/packet.h | 8 ++++---- Source/mpqapi.cpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/dvlnet/abstract_net.cpp b/Source/dvlnet/abstract_net.cpp index d34787d49..984a0b44e 100644 --- a/Source/dvlnet/abstract_net.cpp +++ b/Source/dvlnet/abstract_net.cpp @@ -16,15 +16,15 @@ namespace net { std::unique_ptr abstract_net::make_net(provider_t provider) { #ifdef NONET - return std::unique_ptr(new loopback); + return std::make_unique(); #else switch (provider) { case SELCONN_TCP: - return std::unique_ptr(new cdwrap); + return std::make_unique>(); case SELCONN_ZT: - return std::unique_ptr(new cdwrap>); + return std::make_unique>>(); case SELCONN_LOOPBACK: - return std::unique_ptr(new loopback); + return std::make_unique(); default: ABORT(); } diff --git a/Source/dvlnet/packet.h b/Source/dvlnet/packet.h index 58053b1fa..89f456546 100644 --- a/Source/dvlnet/packet.h +++ b/Source/dvlnet/packet.h @@ -342,19 +342,19 @@ public: inline std::unique_ptr packet_factory::make_packet(buffer_t buf) { - std::unique_ptr ret(new packet_in(key)); + auto ret = std::make_unique(key); ret->create(std::move(buf)); ret->decrypt(); - return std::unique_ptr(std::move(ret)); + return ret; } template std::unique_ptr packet_factory::make_packet(Args... args) { - std::unique_ptr ret(new packet_out(key)); + auto ret = std::make_unique(key); ret->create(args...); ret->encrypt(); - return std::unique_ptr(std::move(ret)); + return ret; } } // namespace net diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 7ee880330..415eacfa9 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -553,7 +553,7 @@ static bool mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, // We populate the table of sector offset while we write the data. // We can't pre-populate it because we don't know the compressed sector sizes yet. // First offset is the start of the first sector, last offset is the end of the last sector. - std::unique_ptr sectoroffsettable(new uint32_t[num_sectors + 1]); + auto sectoroffsettable = std::make_unique(num_sectors + 1); #ifdef CAN_SEEKP_BEYOND_EOF if (!cur_archive.stream.seekp(pBlk->offset + offset_table_bytesize, std::ios::beg)) @@ -566,7 +566,7 @@ static bool mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, const std::uintmax_t cur_size = stream_end - cur_archive.stream_begin; if (cur_size < pBlk->offset + offset_table_bytesize) { if (cur_size < pBlk->offset) { - std::unique_ptr filler(new char[pBlk->offset - cur_size]); + auto filler = std::make_unique(pBlk->offset - cur_size); if (!cur_archive.stream.write(filler.get(), pBlk->offset - cur_size)) return false; }