diff options
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | src/Piece.cc | 5 | ||||
| -rw-r--r-- | src/Piece.h | 6 |
3 files changed, 13 insertions, 4 deletions
@@ -1,5 +1,11 @@ 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. * src/BitfieldManFactory.cc * src/BitfieldManFactory.h diff --git a/src/Piece.cc b/src/Piece.cc index 4c88dd9a..3c71bd8c 100644 --- a/src/Piece.cc +++ b/src/Piece.cc @@ -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; } } diff --git a/src/Piece.h b/src/Piece.h index af2a7a92..02cdeb87 100644 --- a/src/Piece.h +++ b/src/Piece.h @@ -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(); |
