Remove useless DataBuf::clear()

This commit is contained in:
Luis Díaz Más 2022-02-23 22:49:58 +01:00
parent 3a749e6861
commit 5d627433fc
10 changed files with 0 additions and 25 deletions

View File

@ -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;

View File

@ -1019,7 +1019,6 @@ namespace Exiv2 {
auto size = static_cast<uint32_t>(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<uint32_t>(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;

View File

@ -406,7 +406,6 @@ namespace Exiv2 {
enforce(allocate64 <= static_cast<uint64_t>(std::numeric_limits<long>::max()), kerCorruptedMetadata);
const long allocate = static_cast<long>(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.

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -1294,7 +1294,6 @@ namespace Exiv2 {
<< ": Writing offset " << o2 << "\n";
#endif
DataBuf buf(static_cast<long>(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;
}

View File

@ -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 {

View File

@ -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");

View File

@ -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);