2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Destroyed digest context after getting calculated hash.
	* src/Piece.cc
	* src/Piece.h
pull/1/head
Tatsuhiro Tsujikawa 2010-02-11 08:33:58 +00:00
parent 91127ed864
commit 4354c674ab
3 changed files with 13 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Destroyed digest context after getting calculated hash.
* src/Piece.cc
* src/Piece.h
2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed BitfieldManFactory class.

View File

@ -250,13 +250,14 @@ bool Piece::isHashCalculated() const
return !_mdctx.isNull() && _nextBegin == length;
}
// TODO should be getHashString()
std::string Piece::getHashString()
{
if(_mdctx.isNull()) {
return A2STR::NIL;
} else {
return util::toHex(_mdctx->digestFinal());
std::string hash = util::toHex(_mdctx->digestFinal());
destroyHashContext();
return hash;
}
}

View File

@ -164,8 +164,10 @@ public:
bool isHashCalculated() const;
// Returns hash value in ASCII hexadecimal form.
// WARN: This function must be called only once.
// Returns hash value in ASCII hexadecimal form, which is calculated
// by updateHash(). Please note that this function returns hash
// value only once. Second invocation without updateHash() returns
// empty string.
std::string getHashString();
void destroyHashContext();