diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-02-11 08:33:58 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-02-11 08:33:58 +0000 |
| commit | 4354c674abf0bc6b66b88f5f7d0be21b66fc4cd0 (patch) | |
| tree | f7dc6e45b06e3db08c80494c694b5f0f476beab0 | |
| parent | 91127ed864bb6aad0f1f5e12db07d826c660ae5e (diff) | |
2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Destroyed digest context after getting calculated hash.
* src/Piece.cc
* src/Piece.h
| -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(); |
