Index: src/utils/SkSHA1.cpp |
=================================================================== |
--- src/utils/SkSHA1.cpp (revision 8685) |
+++ src/utils/SkSHA1.cpp (working copy) |
@@ -58,7 +58,7 @@ |
this->byteCount += inputLength; |
} |
-void SkSHA1::finish(Digest& digest) { |
+void SkSHA1::finish(SkHashDigest& digest) { |
// Get the number of bits before padding. |
uint8_t bits[8]; |
encode(bits, this->byteCount << 3); |
@@ -78,7 +78,17 @@ |
this->update(bits, 8); |
// Write out digest. |
- encode(digest.data, this->state); |
+ // TODO(epoger): eliminate the extra 20-byte copy, by writing directly into digest.data??? |
+ // NO, we can't do that, because digest.data is immutable (wrapped in SkData). |
+ // Or: |
+ // 1. malloc 20 bytes here (wrapped in an SkData object), |
+ // 2. write the digest into the SkData-wrapped 20 bytes, |
+ // 3. bump the ref counter on that SkData-wrapped 20 bytes, |
+ // 4. replace digest's fSkDataPtr with the new one |
+ size_t digestSize = 20; |
+ uint8_t tempDigestData[digestSize]; |
+ encode(tempDigestData, this->state); |
+ digest.copyFrom(tempDigestData, digestSize); |
#if defined(SK_SHA1_CLEAR_DATA) |
// Clear state. |