diff --git a/src/makernote_int.cpp b/src/makernote_int.cpp index 0b32d84d37..bccc91fb7f 100644 --- a/src/makernote_int.cpp +++ b/src/makernote_int.cpp @@ -139,14 +139,14 @@ bool TiffMnRegistry::operator==(IfdId key) const { return mnGroup_ == key; } -TiffComponent* TiffMnCreator::create(uint16_t tag, IfdId group, const std::string& make, const byte* pData, size_t size, - ByteOrder byteOrder) { +std::unique_ptr TiffMnCreator::create(uint16_t tag, IfdId group, const std::string& make, + const byte* pData, size_t size, ByteOrder byteOrder) { if (auto tmr = Exiv2::find(registry_, make)) return tmr->newMnFct_(tag, group, tmr->mnGroup_, pData, size, byteOrder); return nullptr; } // TiffMnCreator::create -TiffComponent* TiffMnCreator::create(uint16_t tag, IfdId group, IfdId mnGroup) { +std::unique_ptr TiffMnCreator::create(uint16_t tag, IfdId group, IfdId mnGroup) { if (auto tmr = Exiv2::find(registry_, mnGroup)) { if (tmr->newMnFct2_) { return tmr->newMnFct2_(tag, group, mnGroup); @@ -637,20 +637,20 @@ size_t Casio2MnHeader::write(IoWrapper& ioWrapper, ByteOrder /*byteOrder*/) cons // ************************************************************************* // free functions -TiffComponent* newIfdMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* /*pData*/, size_t size, - ByteOrder /*byteOrder*/) { +std::unique_ptr newIfdMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* /*pData*/, size_t size, + ByteOrder /*byteOrder*/) { // Require at least an IFD with 1 entry, but not necessarily a next pointer if (size < 14) return nullptr; return newIfdMn2(tag, group, mnGroup); } -TiffComponent* newIfdMn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, nullptr); +std::unique_ptr newIfdMn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, nullptr); } -TiffComponent* newOlympusMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byte* pData, size_t size, - ByteOrder /*byteOrder*/) { +std::unique_ptr newOlympusMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byte* pData, + size_t size, ByteOrder /*byteOrder*/) { // FIXME: workaround for overwritten OM System header in Olympus files (https://github.com/Exiv2/exiv2/issues/2542) if (size >= 14 && std::string(reinterpret_cast(pData), 14) == std::string("OM SYSTEM\0\0\0II", 14)) { // Require at least the header and an IFD with 1 entry @@ -670,40 +670,40 @@ TiffComponent* newOlympusMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const return newOlympus2Mn2(tag, group, IfdId::olympus2Id); } -TiffComponent* newOlympusMn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new OlympusMnHeader); +std::unique_ptr newOlympusMn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } -TiffComponent* newOlympus2Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new Olympus2MnHeader); +std::unique_ptr newOlympus2Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } -TiffComponent* newOMSystemMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* /*pData*/, size_t size, - ByteOrder /*byteOrder*/) { +std::unique_ptr newOMSystemMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* /*pData*/, + size_t size, ByteOrder /*byteOrder*/) { // Require at least the header and an IFD with 1 entry if (size < OMSystemMnHeader::sizeOfSignature() + 18) return nullptr; return newOMSystemMn2(tag, group, mnGroup); } -TiffComponent* newOMSystemMn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new OMSystemMnHeader); +std::unique_ptr newOMSystemMn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } -TiffComponent* newFujiMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* /*pData*/, size_t size, - ByteOrder /*byteOrder*/) { +std::unique_ptr newFujiMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* /*pData*/, size_t size, + ByteOrder /*byteOrder*/) { // Require at least the header and an IFD with 1 entry if (size < FujiMnHeader::sizeOfSignature() + 18) return nullptr; return newFujiMn2(tag, group, mnGroup); } -TiffComponent* newFujiMn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new FujiMnHeader); +std::unique_ptr newFujiMn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } -TiffComponent* newNikonMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byte* pData, size_t size, - ByteOrder /*byteOrder*/) { +std::unique_ptr newNikonMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byte* pData, size_t size, + ByteOrder /*byteOrder*/) { // If there is no "Nikon" string it must be Nikon1 format if (size < 6 || std::string(reinterpret_cast(pData), 6) != std::string("Nikon\0", 6)) { // Require at least an IFD with 1 entry @@ -727,28 +727,28 @@ TiffComponent* newNikonMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const by return newNikon3Mn2(tag, group, IfdId::nikon3Id); } -TiffComponent* newNikon2Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new Nikon2MnHeader); +std::unique_ptr newNikon2Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } -TiffComponent* newNikon3Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new Nikon3MnHeader); +std::unique_ptr newNikon3Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } -TiffComponent* newPanasonicMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* /*pData*/, size_t size, - ByteOrder /*byteOrder*/) { +std::unique_ptr newPanasonicMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* /*pData*/, + size_t size, ByteOrder /*byteOrder*/) { // Require at least the header and an IFD with 1 entry, but without a next pointer if (size < PanasonicMnHeader::sizeOfSignature() + 14) return nullptr; return newPanasonicMn2(tag, group, mnGroup); } -TiffComponent* newPanasonicMn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new PanasonicMnHeader, false); +std::unique_ptr newPanasonicMn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique(), false); } -TiffComponent* newPentaxMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byte* pData, size_t size, - ByteOrder /*byteOrder*/) { +std::unique_ptr newPentaxMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byte* pData, size_t size, + ByteOrder /*byteOrder*/) { if (size > 8 && std::string(reinterpret_cast(pData), 8) == std::string("PENTAX \0", 8)) { // Require at least the header and an IFD with 1 entry if (size < PentaxDngMnHeader::sizeOfSignature() + 18) @@ -764,16 +764,16 @@ TiffComponent* newPentaxMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const b return nullptr; } -TiffComponent* newPentaxMn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new PentaxMnHeader); +std::unique_ptr newPentaxMn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } -TiffComponent* newPentaxDngMn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new PentaxDngMnHeader); +std::unique_ptr newPentaxDngMn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } -TiffComponent* newSamsungMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, - ByteOrder /*byteOrder*/) { +std::unique_ptr newSamsungMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder /*byteOrder*/) { if (size > 4 && std::string(reinterpret_cast(pData), 4) == std::string("AOC\0", 4)) { // Samsung branded Pentax camera: // Require at least the header and an IFD with 1 entry @@ -788,24 +788,24 @@ TiffComponent* newSamsungMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte return newSamsungMn2(tag, group, mnGroup); } -TiffComponent* newSamsungMn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new SamsungMnHeader); +std::unique_ptr newSamsungMn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } -TiffComponent* newSigmaMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* /*pData*/, size_t size, - ByteOrder /*byteOrder*/) { +std::unique_ptr newSigmaMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* /*pData*/, size_t size, + ByteOrder /*byteOrder*/) { // Require at least the header and an IFD with 1 entry if (size < SigmaMnHeader::sizeOfSignature() + 18) return nullptr; return newSigmaMn2(tag, group, mnGroup); } -TiffComponent* newSigmaMn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new SigmaMnHeader); +std::unique_ptr newSigmaMn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } -TiffComponent* newSonyMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byte* pData, size_t size, - ByteOrder /*byteOrder*/) { +std::unique_ptr newSonyMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byte* pData, size_t size, + ByteOrder /*byteOrder*/) { // If there is no "SONY DSC " string we assume it's a simple IFD Makernote if (size < 12 || std::string(reinterpret_cast(pData), 12) != std::string("SONY DSC \0\0\0", 12)) { // Require at least an IFD with 1 entry @@ -819,16 +819,16 @@ TiffComponent* newSonyMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byt return newSony1Mn2(tag, group, IfdId::sony1Id); } -TiffComponent* newSony1Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new SonyMnHeader, false); +std::unique_ptr newSony1Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique(), false); } -TiffComponent* newSony2Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, nullptr, true); +std::unique_ptr newSony2Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, nullptr, true); } -TiffComponent* newCasioMn(uint16_t tag, IfdId group, IfdId /* mnGroup*/, const byte* pData, size_t size, - ByteOrder /* byteOrder */) { +std::unique_ptr newCasioMn(uint16_t tag, IfdId group, IfdId /* mnGroup*/, const byte* pData, size_t size, + ByteOrder /* byteOrder */) { if (size > 6 && std::string(reinterpret_cast(pData), 6) == std::string("QVC\0\0\0", 6)) return newCasio2Mn2(tag, group, IfdId::casio2Id); // Require at least an IFD with 1 entry, but not necessarily a next pointer @@ -837,8 +837,8 @@ TiffComponent* newCasioMn(uint16_t tag, IfdId group, IfdId /* mnGroup*/, const b return newIfdMn2(tag, group, IfdId::casioId); } -TiffComponent* newCasio2Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { - return new TiffIfdMakernote(tag, group, mnGroup, new Casio2MnHeader); +std::unique_ptr newCasio2Mn2(uint16_t tag, IfdId group, IfdId mnGroup) { + return std::make_unique(tag, group, mnGroup, std::make_unique()); } //! Structure for an index into the array set of complex binary arrays. diff --git a/src/makernote_int.hpp b/src/makernote_int.hpp index e9f9ed8470..a778dcd41b 100644 --- a/src/makernote_int.hpp +++ b/src/makernote_int.hpp @@ -28,10 +28,10 @@ std::string readExiv2Config(const std::string& section, const std::string& value // class definitions //! Type for a pointer to a function creating a makernote (image) -using NewMnFct = TiffComponent* (*)(uint16_t, IfdId, IfdId, const byte*, size_t, ByteOrder); +using NewMnFct = std::unique_ptr (*)(uint16_t, IfdId, IfdId, const byte*, size_t, ByteOrder); //! Type for a pointer to a function creating a makernote (group) -using NewMnFct2 = TiffComponent* (*)(uint16_t tag, IfdId group, IfdId mnGroup); +using NewMnFct2 = std::unique_ptr (*)(uint16_t tag, IfdId group, IfdId mnGroup); //! Makernote registry structure struct TiffMnRegistry { @@ -71,13 +71,13 @@ class TiffMnCreator { is used to indicate this transfer here in order to reduce file dependencies. */ - static TiffComponent* create(uint16_t tag, IfdId group, const std::string& make, const byte* pData, size_t size, - ByteOrder byteOrder); + static std::unique_ptr create(uint16_t tag, IfdId group, const std::string& make, const byte* pData, + size_t size, ByteOrder byteOrder); /*! @brief Create the Makernote for a given group. This method is used when a makernote is written back from Exif tags. */ - static TiffComponent* create(uint16_t tag, IfdId group, IfdId mnGroup); + static std::unique_ptr create(uint16_t tag, IfdId group, IfdId mnGroup); ~TiffMnCreator() = default; //! Prevent destruction (needed if used as a policy class) @@ -502,93 +502,96 @@ class Casio2MnHeader : public MnHeader { // template, inline and free functions //! Function to create a simple IFD makernote (Canon, Minolta, Nikon1) -TiffComponent* newIfdMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, ByteOrder byteOrder); +std::unique_ptr newIfdMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create a simple IFD makernote (Canon, Minolta, Nikon1) -TiffComponent* newIfdMn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newIfdMn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create an Olympus makernote -TiffComponent* newOlympusMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, - ByteOrder byteOrder); +std::unique_ptr newOlympusMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create an Olympus makernote -TiffComponent* newOlympusMn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newOlympusMn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create an Olympus II makernote -TiffComponent* newOlympus2Mn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newOlympus2Mn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create an OM Digital Solutions makernote -TiffComponent* newOMSystemMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, - ByteOrder byteOrder); +std::unique_ptr newOMSystemMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create an OM Digital Solutions makernote -TiffComponent* newOMSystemMn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newOMSystemMn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create a Fujifilm makernote -TiffComponent* newFujiMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, ByteOrder byteOrder); +std::unique_ptr newFujiMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create a Fujifilm makernote -TiffComponent* newFujiMn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newFujiMn2(uint16_t tag, IfdId group, IfdId mnGroup); /*! @brief Function to create a Nikon makernote. This will create the appropriate Nikon 1, 2 or 3 makernote, based on the arguments. */ -TiffComponent* newNikonMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, - ByteOrder byteOrder); +std::unique_ptr newNikonMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create a Nikon2 makernote -TiffComponent* newNikon2Mn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newNikon2Mn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create a Nikon3 makernote -TiffComponent* newNikon3Mn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newNikon3Mn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create a Panasonic makernote -TiffComponent* newPanasonicMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, - ByteOrder byteOrder); +std::unique_ptr newPanasonicMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create a Panasonic makernote -TiffComponent* newPanasonicMn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newPanasonicMn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create an Pentax makernote -TiffComponent* newPentaxMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, - ByteOrder byteOrder); +std::unique_ptr newPentaxMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create an Pentax makernote -TiffComponent* newPentaxMn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newPentaxMn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create an Pentax DNG makernote -TiffComponent* newPentaxDngMn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newPentaxDngMn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create a Samsung makernote -TiffComponent* newSamsungMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, - ByteOrder byteOrder); +std::unique_ptr newSamsungMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create a Samsung makernote -TiffComponent* newSamsungMn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newSamsungMn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create a Sigma makernote -TiffComponent* newSigmaMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, - ByteOrder byteOrder); +std::unique_ptr newSigmaMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create a Sigma makernote -TiffComponent* newSigmaMn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newSigmaMn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create a Sony makernote -TiffComponent* newSonyMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, ByteOrder byteOrder); +std::unique_ptr newSonyMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create a Sony1 makernote -TiffComponent* newSony1Mn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newSony1Mn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create a Sony2 makernote -TiffComponent* newSony2Mn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newSony2Mn2(uint16_t tag, IfdId group, IfdId mnGroup); //! Function to create a Casio2 makernote -TiffComponent* newCasioMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, - ByteOrder byteOrder); +std::unique_ptr newCasioMn(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size, + ByteOrder byteOrder); //! Function to create a Casio2 makernote -TiffComponent* newCasio2Mn2(uint16_t tag, IfdId group, IfdId mnGroup); +std::unique_ptr newCasio2Mn2(uint16_t tag, IfdId group, IfdId mnGroup); /*! @brief Function to select cfg + def of the Sony Camera Settings complex binary array. diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 1478a9f71d..07c9a6c843 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -70,8 +70,9 @@ TiffSubIfd::TiffSubIfd(uint16_t tag, IfdId group, IfdId newGroup) : TiffEntryBase(tag, group, ttUnsignedLong), newGroup_(newGroup) { } -TiffIfdMakernote::TiffIfdMakernote(uint16_t tag, IfdId group, IfdId mnGroup, MnHeader* pHeader, bool hasNext) : - TiffComponent(tag, group), pHeader_(pHeader), ifd_(tag, mnGroup, hasNext) { +TiffIfdMakernote::TiffIfdMakernote(uint16_t tag, IfdId group, IfdId mnGroup, std::unique_ptr pHeader, + bool hasNext) : + TiffComponent(tag, group), pHeader_(std::move(pHeader)), ifd_(tag, mnGroup, hasNext) { } TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArrayCfg& arrayCfg, const ArrayDef* arrayDef, @@ -105,14 +106,6 @@ TiffEntryBase::~TiffEntryBase() { delete pValue_; } -TiffMnEntry::~TiffMnEntry() { - delete mn_; -} - -TiffIfdMakernote::~TiffIfdMakernote() { - delete pHeader_; -} - TiffBinaryArray::~TiffBinaryArray() { for (auto&& element : elements_) { delete element; @@ -673,7 +666,6 @@ void TiffMnEntry::doAccept(TiffVisitor& visitor) { if (mn_) mn_->accept(visitor); if (!visitor.go(TiffVisitor::geKnownMakernote)) { - delete mn_; mn_ = nullptr; } diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 4506a4dca0..0e28aba912 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -1016,18 +1016,6 @@ class TiffMnEntry : public TiffEntryBase { TiffEntryBase(tag, group, ttUndefined), mnGroup_(mnGroup) { } - //! Virtual destructor - ~TiffMnEntry() override; - //@} - - //! @name NOT implemented - //@{ - //! Copy constructor. - TiffMnEntry(const TiffMnEntry&) = delete; - //! Assignment operator. - TiffMnEntry& operator=(const TiffMnEntry&) = delete; - //@} - protected: //! @name Protected Manipulators //@{ @@ -1063,8 +1051,8 @@ class TiffMnEntry : public TiffEntryBase { private: // DATA - IfdId mnGroup_; //!< New group for concrete mn - TiffComponent* mn_{}; //!< The Makernote + IfdId mnGroup_; //!< New group for concrete mn + std::unique_ptr mn_; //!< The Makernote }; /*! @@ -1083,9 +1071,9 @@ class TiffIfdMakernote : public TiffComponent { //! @name Creators //@{ //! Default constructor - TiffIfdMakernote(uint16_t tag, IfdId group, IfdId mnGroup, MnHeader* pHeader, bool hasNext = true); + TiffIfdMakernote(uint16_t tag, IfdId group, IfdId mnGroup, std::unique_ptr pHeader, bool hasNext = true); //! Virtual destructor - ~TiffIfdMakernote() override; + ~TiffIfdMakernote() override = default; //@} /*! @@ -1211,7 +1199,7 @@ class TiffIfdMakernote : public TiffComponent { private: // DATA - MnHeader* pHeader_; //!< Makernote header + std::unique_ptr pHeader_; //!< Makernote header TiffDirectory ifd_; //!< Makernote IFD size_t mnOffset_{}; //!< Makernote offset ByteOrder imageByteOrder_{invalidByteOrder}; //!< Byte order for the image diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index d519ca0c4d..0fd81890d4 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -963,7 +963,7 @@ void TiffEncoder::add(TiffComponent* pRootDir, TiffComponent* pSourceDir, uint32 TiffFinder finder(0x927c, IfdId::exifId); pRootDir->accept(finder); if (auto te = dynamic_cast(finder.result())) { - if (auto tim = dynamic_cast(te->mn_)) { + if (auto tim = dynamic_cast(te->mn_.get())) { // Set Makernote byte order ByteOrder bo = stringToByteOrder(posBo->toString()); if (bo != invalidByteOrder)