Skip to content

Commit

Permalink
use unique_ptr constructor instead of make_unique (C++14+ only)
Browse files Browse the repository at this point in the history
  • Loading branch information
tfussell committed Jul 3, 2017
1 parent 498f3a6 commit 9f95894
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source/detail/serialization/zstream.cpp
Expand Up @@ -482,7 +482,9 @@ std::unique_ptr<std::streambuf> ozstream::open(const path &filename)
zheader header;
header.filename = filename.string();
file_headers_.push_back(header);
return std::make_unique<zip_streambuf_compress>(&file_headers_.back(), destination_stream_);
auto buffer = new zip_streambuf_compress(&file_headers_.back(), destination_stream_);

return std::unique_ptr<zip_streambuf_compress>(buffer);
}

izstream::izstream(std::istream &stream)
Expand Down Expand Up @@ -526,7 +528,7 @@ bool izstream::read_central_header()
}

source_stream_.read(reinterpret_cast<char *>(buf.data()), read_start);

if (buf[0] == 0xd0 && buf[1] == 0xcf && buf[2] == 0x11 && buf[3] == 0xe0
&& buf[4] == 0xa1 && buf[5] == 0xb1 && buf[6] == 0x1a && buf[7] == 0xe1)
{
Expand Down Expand Up @@ -595,7 +597,9 @@ std::unique_ptr<std::streambuf> izstream::open(const path &filename) const

auto header = file_headers_.at(filename.string());
source_stream_.seekg(header.header_offset);
return std::make_unique<zip_streambuf_decompress>(source_stream_, header);
auto buffer = new zip_streambuf_decompress(source_stream_, header);

return std::unique_ptr<zip_streambuf_decompress>(buffer);
}

std::string izstream::read(const path &filename) const
Expand Down

0 comments on commit 9f95894

Please sign in to comment.