diff --git a/include/exiv2/types.hpp b/include/exiv2/types.hpp index b88c8f74..78c19196 100644 --- a/include/exiv2/types.hpp +++ b/include/exiv2/types.hpp @@ -190,9 +190,6 @@ namespace Exiv2 { void reset(); //@} - //! Fill the buffer with zeros. - void clear(); - long size() const { return pData_.size(); } uint8_t read_uint8(size_t offset) const; diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index 76f71242..6cb86baf 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -1019,7 +1019,6 @@ namespace Exiv2 { auto size = static_cast(comment.size()); if (cc && cc->size() > size) size = cc->size(); DataBuf buf(size); - buf.clear(); buf.copyBytes(0, comment.data(), comment.size()); pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf)); } @@ -1027,7 +1026,6 @@ namespace Exiv2 { if (cc) { // Just delete the value, do not remove the tag DataBuf buf(cc->size()); - buf.clear(); cc->setValue(std::move(buf)); } } @@ -1117,7 +1115,6 @@ namespace Exiv2 { } if (t != 0) { DataBuf buf(12); - buf.clear(); buf.write_uint32(0, static_cast(t), pHead->byteOrder()); pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf)); } @@ -1152,7 +1149,6 @@ namespace Exiv2 { size = cc->size(); } DataBuf buf(size); - buf.clear(); if (cc) buf.copyBytes(8, cc->pData() + 8, cc->size() - 8); if (edX != edEnd && edX->size() == 4) { edX->copy(buf.data(), pHead->byteOrder()); @@ -1197,7 +1193,6 @@ namespace Exiv2 { { const uint16_t size = 1024; DataBuf buf(size); - buf.clear(); uint16_t len = 0; diff --git a/src/image.cpp b/src/image.cpp index 945747ad..c7022951 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -406,7 +406,6 @@ namespace Exiv2 { enforce(allocate64 <= static_cast(std::numeric_limits::max()), kerCorruptedMetadata); const long allocate = static_cast(allocate64); DataBuf buf(allocate); // allocate a buffer - buf.clear(); buf.copyBytes(0, dir.c_data(8), 4); // copy dir[8:11] into buffer (short strings) // We have already checked that this multiplication cannot overflow. diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 078e3a4d..1778f634 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -766,8 +766,6 @@ static void boxes_check(size_t b,size_t m) #endif // Read chunk header. - - bheaderBuf.clear(); long bufRead = io_->read(bheaderBuf.data(), bheaderBuf.size()); if (io_->error()) throw Error(kerFailedToReadImageData); if (bufRead != bheaderBuf.size()) throw Error(kerInputDataReadFailed); diff --git a/src/pgfimage.cpp b/src/pgfimage.cpp index e21f0817..d6e3ae82 100644 --- a/src/pgfimage.cpp +++ b/src/pgfimage.cpp @@ -138,7 +138,6 @@ namespace Exiv2 { if (size == 0) return; DataBuf imgData(size); - imgData.clear(); long bufRead = io_->read(imgData.data(), imgData.size()); if (io_->error()) throw Error(kerFailedToReadImageData); if (bufRead != imgData.size()) throw Error(kerInputDataReadFailed); diff --git a/src/pngimage.cpp b/src/pngimage.cpp index 90ece7cf..6c567084 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -246,7 +246,6 @@ namespace Exiv2 { while( !io_->eof() && ::strcmp(chType,"IEND") ) { size_t address = io_->tell(); - cheaderBuf.clear(); long bufRead = io_->read(cheaderBuf.data(), cheaderBuf.size()); if (io_->error()) throw Error(kerFailedToReadImageData); if (bufRead != cheaderBuf.size()) throw Error(kerInputDataReadFailed); @@ -440,7 +439,6 @@ namespace Exiv2 { while(!io_->eof()) { - cheaderBuf.clear(); readChunk(cheaderBuf, *io_); // Read chunk header. // Decode chunk data length. @@ -560,8 +558,6 @@ namespace Exiv2 { while(!io_->eof()) { // Read chunk header. - - cheaderBuf.clear(); long bufRead = io_->read(cheaderBuf.data(), 8); if (io_->error()) throw Error(kerFailedToReadImageData); if (bufRead != 8) throw Error(kerInputDataReadFailed); diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index a2ce2ef3..983900fa 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -1294,7 +1294,6 @@ namespace Exiv2 { << ": Writing offset " << o2 << "\n"; #endif DataBuf buf(static_cast(strips_.size()) * 4); - buf.clear(); uint32_t idx = 0; for (auto&& strip : strips_) { idx += writeOffset(buf.data(idx), o2, tiffType(), byteOrder); @@ -1905,7 +1904,6 @@ namespace { { if (curr < tobe) { Exiv2::DataBuf buf(tobe - curr); - buf.clear(); ioWrapper.write(buf.c_data(), buf.size()); return tobe - curr; } diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 8ea7b31a..575afe99 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -624,7 +624,6 @@ namespace Exiv2 { if (rawIptc.size() % 4 != 0) { // Pad the last unsignedLong value with 0s buf.alloc((rawIptc.size() / 4) * 4 + 4); - buf.clear(); buf.copyBytes(0, rawIptc.c_data(), rawIptc.size()); } else { diff --git a/src/types.cpp b/src/types.cpp index 9db1db5a..7cc19277 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -141,10 +141,6 @@ namespace Exiv2 { pData_.clear(); } - void DataBuf::clear() { - std::fill(pData_.begin(), pData_.end(), 0); - } - uint8_t Exiv2::DataBuf::read_uint8(size_t offset) const { if (offset >= pData_.size()) { throw std::overflow_error("Overflow in Exiv2::DataBuf::read_uint8"); @@ -201,7 +197,6 @@ namespace Exiv2 { ull2Data(&pData_[offset], x, byteOrder); } - /// \todo do not use void* void Exiv2::DataBuf::copyBytes(size_t offset, const void* buf, size_t bufsize) { if (pData_.size() < bufsize || offset > pData_.size() - bufsize) { throw std::overflow_error("Overflow in Exiv2::DataBuf::copyBytes"); diff --git a/unitTests/test_types.cpp b/unitTests/test_types.cpp index 96c5742c..2d050209 100644 --- a/unitTests/test_types.cpp +++ b/unitTests/test_types.cpp @@ -62,7 +62,6 @@ TEST(DataBuf, allocatesDataWithNonEmptyConstructor) TEST(DataBuf, read_write_endianess) { DataBuf buf(4 + 1 + 2 + 4 + 8); - buf.clear(); // Big endian. buf.write_uint8(4, 0x01);