remove some unique_ptrs

They're not really used as pointers.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 3 years ago
parent 053f516072
commit 0d971e98e4

@ -92,10 +92,10 @@ void CrwImage::writeMetadata() {
CrwParser::encode(blob, buf.c_data(), buf.size(), this);
// Write new buffer to file
auto tempIo = std::make_unique<MemIo>();
tempIo->write((!blob.empty() ? &blob[0] : nullptr), blob.size());
MemIo tempIo;
tempIo.write((!blob.empty() ? &blob[0] : nullptr), blob.size());
io_->close();
io_->transfer(*tempIo); // may throw
io_->transfer(tempIo); // may throw
} // CrwImage::writeMetadata

@ -791,8 +791,7 @@ Image::UniquePtr ImageFactory::open(const std::string& path, bool useCurl) {
}
Image::UniquePtr ImageFactory::open(const byte* data, size_t size) {
auto io = std::make_unique<MemIo>(data, size);
auto image = open(std::move(io)); // may throw
auto image = open(std::make_unique<MemIo>(data, size)); // may throw
if (!image)
throw Error(ErrorCode::kerMemoryContainsUnknownImageType);
return image;
@ -826,8 +825,7 @@ Image::UniquePtr ImageFactory::create(ImageType type, const std::string& path) {
}
Image::UniquePtr ImageFactory::create(ImageType type) {
auto io = std::make_unique<MemIo>();
auto image = create(type, std::move(io));
auto image = create(type, std::make_unique<MemIo>());
if (!image)
throw Error(ErrorCode::kerUnsupportedImageType, static_cast<int>(type));
return image;

@ -585,11 +585,11 @@ void Jp2Image::writeMetadata() {
throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique<MemIo>();
MemIo tempIo;
doWriteMetadata(*tempIo); // may throw
doWriteMetadata(tempIo); // may throw
io_->close();
io_->transfer(*tempIo); // may throw
io_->transfer(tempIo); // may throw
} // Jp2Image::writeMetadata

@ -696,7 +696,7 @@ void JpegBase::printStructure(std::ostream& out, PrintStructureOption option, in
// exiv2 -pS E.jpg
// binary copy io_ to a temporary file
auto tempIo = std::make_unique<MemIo>();
MemIo tempIo;
for (size_t i = 0; i < (count / 2) + 1; i++) {
size_t start = pos[2 * i] + 2; // step JPG 2 byte marker
if (start == 2)
@ -709,12 +709,12 @@ void JpegBase::printStructure(std::ostream& out, PrintStructureOption option, in
io_->seekOrThrow(start, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
DataBuf buf(length);
io_->readOrThrow(buf.data(), buf.size(), ErrorCode::kerFailedToReadImageData);
tempIo->write(buf.c_data(), buf.size());
tempIo.write(buf.c_data(), buf.size());
}
}
io_->seekOrThrow(0, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
io_->transfer(*tempIo); // may throw
io_->transfer(tempIo); // may throw
io_->seekOrThrow(0, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
readMetadata();
}
@ -725,11 +725,11 @@ void JpegBase::writeMetadata() {
throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique<MemIo>();
MemIo tempIo;
doWriteMetadata(*tempIo); // may throw
doWriteMetadata(tempIo); // may throw
io_->close();
io_->transfer(*tempIo); // may throw
io_->transfer(tempIo); // may throw
}
DataBuf JpegBase::readNextSegment(byte marker) {

@ -120,11 +120,11 @@ void PgfImage::writeMetadata() {
throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique<MemIo>();
MemIo tempIo;
doWriteMetadata(*tempIo); // may throw
doWriteMetadata(tempIo); // may throw
io_->close();
io_->transfer(*tempIo); // may throw
io_->transfer(tempIo); // may throw
} // PgfImage::writeMetadata

@ -480,11 +480,11 @@ void PngImage::writeMetadata() {
throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique<MemIo>();
MemIo tempIo;
doWriteMetadata(*tempIo); // may throw
doWriteMetadata(tempIo); // may throw
io_->close();
io_->transfer(*tempIo); // may throw
io_->transfer(tempIo); // may throw
} // PngImage::writeMetadata

@ -314,11 +314,11 @@ void PsdImage::writeMetadata() {
throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique<MemIo>();
MemIo tempIo;
doWriteMetadata(*tempIo); // may throw
doWriteMetadata(tempIo); // may throw
io_->close();
io_->transfer(*tempIo); // may throw
io_->transfer(tempIo); // may throw
} // PsdImage::writeMetadata

@ -513,8 +513,7 @@ TiffComponent* TiffSubIfd::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffCompo
if (tiffPath.size() == 1 && object) {
tc = addChild(std::move(object));
} else {
auto atc = std::make_unique<TiffDirectory>(tpi1.tag(), tpi2.group());
tc = addChild(std::move(atc));
tc = addChild(std::make_unique<TiffDirectory>(tpi1.tag(), tpi2.group()));
}
setCount(ifds_.size());
}

@ -1890,13 +1890,13 @@ WriteMethod TiffParserWorker::encode(BasicIo& io, const byte* pData, size_t size
encoder.add(createdTree.get(), parsedTree.get(), root);
// Write binary representation from the composite tree
DataBuf header = pHeader->write();
auto tempIo = std::make_unique<MemIo>();
IoWrapper ioWrapper(*tempIo, header.c_data(), header.size(), pOffsetWriter);
auto tempIo = MemIo();
IoWrapper ioWrapper(tempIo, header.c_data(), header.size(), pOffsetWriter);
auto imageIdx(uint32_t(-1));
createdTree->write(ioWrapper, pHeader->byteOrder(), header.size(), uint32_t(-1), uint32_t(-1), imageIdx);
if (pOffsetWriter)
pOffsetWriter->writeOffsets(*tempIo);
io.transfer(*tempIo); // may throw
pOffsetWriter->writeOffsets(tempIo);
io.transfer(tempIo); // may throw
#ifndef SUPPRESS_WARNINGS
EXV_INFO << "Write strategy: Intrusive\n";
#endif

@ -96,11 +96,11 @@ void WebPImage::writeMetadata() {
throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique<MemIo>();
MemIo tempIo;
doWriteMetadata(*tempIo); // may throw
doWriteMetadata(tempIo); // may throw
io_->close();
io_->transfer(*tempIo); // may throw
io_->transfer(tempIo); // may throw
} // WebPImage::writeMetadata
void WebPImage::doWriteMetadata(BasicIo& outIo) {

@ -140,15 +140,15 @@ void XmpSidecar::writeMetadata() {
if (xmpPacket_.substr(0, 5) != "<?xml") {
xmpPacket_ = xmlHeader + xmpPacket_ + xmlFooter;
}
auto tempIo = std::make_unique<MemIo>();
MemIo tempIo;
// Write XMP packet
if (tempIo->write(reinterpret_cast<const byte*>(xmpPacket_.data()), xmpPacket_.size()) != xmpPacket_.size())
if (tempIo.write(reinterpret_cast<const byte*>(xmpPacket_.data()), xmpPacket_.size()) != xmpPacket_.size())
throw Error(ErrorCode::kerImageWriteFailed);
if (tempIo->error())
if (tempIo.error())
throw Error(ErrorCode::kerImageWriteFailed);
io_->close();
io_->transfer(*tempIo); // may throw
io_->transfer(tempIo); // may throw
}
} // XmpSidecar::writeMetadata

Loading…
Cancel
Save