Skip to content

Commit

Permalink
use make_unique
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Dec 18, 2024
1 parent 5c02915 commit 511aa05
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/torrent/data/file_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ FileList::create_chunk(uint64_t offset, uint32_t length, int prot) {
if (offset + length > m_torrentSize)
throw internal_error("Tried to access chunk out of range in FileList", data()->hash());

std::unique_ptr<Chunk> chunk(new Chunk);
auto chunk = std::make_unique<Chunk>();

auto itr = std::find_if(begin(), end(), [offset](File* file) { return file->is_valid_position(offset); });

Expand Down
2 changes: 1 addition & 1 deletion src/torrent/torrent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ encoding_list() {

Download
download_add(Object* object) {
std::unique_ptr<DownloadWrapper> download(new DownloadWrapper);
auto download = std::make_unique<DownloadWrapper>();

DownloadConstructor ctor;
ctor.set_download(download.get());
Expand Down
4 changes: 2 additions & 2 deletions src/torrent/utils/thread_interrupt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ thread_interrupt::create_pair() {

pair_type result;

result.first = std::unique_ptr<thread_interrupt>(new thread_interrupt(fd1));
result.second = std::unique_ptr<thread_interrupt>(new thread_interrupt(fd2));
result.first = std::make_unique<thread_interrupt>(fd1);
result.second = std::make_unique<thread_interrupt>(fd2);

result.first->m_other = result.second.get();
result.second->m_other = result.first.get();
Expand Down

0 comments on commit 511aa05

Please sign in to comment.