diff --git a/src/IteratableChecksumValidator.cc b/src/IteratableChecksumValidator.cc index 20b1b5cc..29451d4f 100644 --- a/src/IteratableChecksumValidator.cc +++ b/src/IteratableChecksumValidator.cc @@ -49,30 +49,23 @@ namespace aria2 { -#define BUFSIZE (256*1024) -#define ALIGNMENT 512 - IteratableChecksumValidator::IteratableChecksumValidator (const SharedHandle& dctx, const PieceStorageHandle& pieceStorage) : dctx_(dctx), pieceStorage_(pieceStorage), - currentOffset_(0), - buffer_(0) + currentOffset_(0) {} -IteratableChecksumValidator::~IteratableChecksumValidator() -{ - delete [] buffer_; -} +IteratableChecksumValidator::~IteratableChecksumValidator() {} void IteratableChecksumValidator::validateChunk() { if(!finished()) { - size_t length = pieceStorage_->getDiskAdaptor()->readData(buffer_, - BUFSIZE, - currentOffset_); - ctx_->update(buffer_, length); + unsigned char buf[4096]; + size_t length = pieceStorage_->getDiskAdaptor()->readData + (buf, sizeof(buf), currentOffset_); + ctx_->update(buf, length); currentOffset_ += length; if(finished()) { std::string actualDigest = ctx_->digest(); @@ -105,8 +98,6 @@ uint64_t IteratableChecksumValidator::getTotalLength() const void IteratableChecksumValidator::init() { - delete [] buffer_; - buffer_ = new unsigned char[BUFSIZE]; currentOffset_ = 0; ctx_ = MessageDigest::create(dctx_->getHashType()); } diff --git a/src/IteratableChecksumValidator.h b/src/IteratableChecksumValidator.h index bdc20f82..d38fb42c 100644 --- a/src/IteratableChecksumValidator.h +++ b/src/IteratableChecksumValidator.h @@ -53,8 +53,6 @@ private: off_t currentOffset_; SharedHandle ctx_; - - unsigned char* buffer_; public: IteratableChecksumValidator(const SharedHandle& dctx, const SharedHandle& pieceStorage);