2010-05-09 Fumitoshi Ukai <ukai@chromium.org>
authorukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 May 2010 07:02:34 +0000 (07:02 +0000)
committerukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 May 2010 07:02:34 +0000 (07:02 +0000)
        Reviewed by Eric Seidel.

        JavaScriptCore/wtf/MD5.h: checksum should take a reference to output.
        https://bugs.webkit.org/show_bug.cgi?id=38723

        * JavaScriptCore.exp:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
        * wtf/MD5.cpp:
        (WTF::expectMD5):
          Fix for checksum change.
        (WTF::MD5::checksum):
          Take a reference to output, instead of returning the result by value, to reduce coping for performance.
        * wtf/MD5.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@59067 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
JavaScriptCore/wtf/MD5.cpp
JavaScriptCore/wtf/MD5.h

index 5c82536..aea20a4 100644 (file)
@@ -1,3 +1,19 @@
+2010-05-09  Fumitoshi Ukai  <ukai@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        JavaScriptCore/wtf/MD5.h: checksum should take a reference to output.
+        https://bugs.webkit.org/show_bug.cgi?id=38723
+
+        * JavaScriptCore.exp:
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+        * wtf/MD5.cpp:
+        (WTF::expectMD5):
+          Fix for checksum change.
+        (WTF::MD5::checksum):
+          Take a reference to output, instead of returning the result by value, to reduce coping for performance.
+        * wtf/MD5.h:
+
 2010-05-09  Oliver Hunt  <oliver@apple.com>
 
         Build fix.
index e77028d..96d4c40 100644 (file)
@@ -349,7 +349,7 @@ __ZN3WTF37parseDateFromNullTerminatedCharactersEPKc
 __ZN3WTF38unlockAtomicallyInitializedStaticMutexEv
 __ZN3WTF39initializeMainThreadToProcessMainThreadEv
 __ZN3WTF3MD58addBytesEPKhm
-__ZN3WTF3MD58checksumEv
+__ZN3WTF3MD58checksumERNS_6VectorIhLm16EEE
 __ZN3WTF3MD5C1Ev
 __ZN3WTF5Mutex4lockEv
 __ZN3WTF5Mutex6unlockEv
index 4e1a8d4..f2227a7 100644 (file)
@@ -89,7 +89,7 @@ EXPORTS
     ?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVExecState@2@@Z
     ?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVJSGlobalData@2@@Z
     ?checkSyntax@JSC@@YA?AVCompletion@1@PAVExecState@1@ABVSourceCode@1@@Z
-    ?checksum@MD5@WTF@@QAE?AV?$Vector@E$0BA@@2@XZ
+    ?checksum@MD5@WTF@@QAEXAAV?$Vector@E$0BA@@2@@Z
     ?classInfo@InternalFunction@JSC@@UBEPBUClassInfo@2@XZ
     ?classInfo@JSCell@JSC@@UBEPBUClassInfo@2@XZ
     ?className@JSObject@JSC@@UBE?AVUString@2@XZ
index cd1837a..e995102 100644 (file)
@@ -67,7 +67,8 @@ static void expectMD5(CString input, CString expected)
 {
     MD5 md5;
     md5.addBytes(reinterpret_cast<const uint8_t*>(input.data()), input.length());
-    Vector<uint8_t, 16> digest = md5.checksum();
+    Vector<uint8_t, 16> digest;
+    md5.checksum(digest);
     char* buf = 0;
     CString actual = CString::newUninitialized(32, buf);
     for (size_t i = 0; i < 16; i++) {
@@ -256,7 +257,7 @@ void MD5::addBytes(const uint8_t* input, size_t length)
     memcpy(m_in, buf, length);
 }
 
-Vector<uint8_t, 16> MD5::checksum()
+void MD5::checksum(Vector<uint8_t, 16>& digest)
 {
     // Compute number of bytes mod 64
     unsigned count = (m_bits[0] >> 3) & 0x3F;
@@ -291,14 +292,16 @@ Vector<uint8_t, 16> MD5::checksum()
 
     MD5Transform(m_buf, reinterpret_cast<uint32_t*>(m_in));
     reverseBytes(reinterpret_cast<uint8_t*>(m_buf), 4);
-    Vector<uint8_t, 16> digest;
+
+    // Now, m_buf contains checksum result.
+    if (!digest.isEmpty())
+        digest.clear();
     digest.append(reinterpret_cast<uint8_t*>(m_buf), 16);
 
     // In case it's sensitive
     memset(m_buf, 0, sizeof(m_buf));
     memset(m_bits, 0, sizeof(m_bits));
     memset(m_in, 0, sizeof(m_in));
-    return digest;
 }
 
 } // namespace WTF
index 8ebfc45..3caa810 100644 (file)
@@ -46,7 +46,7 @@ public:
     void addBytes(const uint8_t* input, size_t length);
 
     // checksum has a side effect of resetting the state of the object.
-    Vector<uint8_t, 16> checksum();
+    void checksum(Vector<uint8_t, 16>&);
 
 private:
     uint32_t m_buf[4];