Fix a -Wunused-local-typedefs warning
[oota-llvm.git] / lib / Support / MD5.cpp
index 6cd040bd1b541a1de3b010d39b4a9efca99722ab..514466c750fcc911947581de151cbe14c127c53f 100644 (file)
@@ -72,8 +72,8 @@ namespace llvm {
 
 /// \brief This processes one or more 64-byte data blocks, but does NOT update
 ///the bit counters.  There are no alignment requirements.
-const unsigned char *MD5::body(ArrayRef<unsigned char> Data) {
-  const unsigned char *ptr;
+const uint8_t *MD5::body(ArrayRef<uint8_t> Data) {
+  const uint8_t *ptr;
   MD5_u32plus a, b, c, d;
   MD5_u32plus saved_a, saved_b, saved_c, saved_d;
   unsigned long Size = Data.size();
@@ -183,11 +183,11 @@ MD5::MD5()
     : a(0x67452301), b(0xefcdab89), c(0x98badcfe), d(0x10325476), hi(0), lo(0) {
 }
 
-/// Incrementally add \p size of \p data to the hash.
-void MD5::update(ArrayRef<unsigned char> Data) {
+/// Incrementally add the bytes in \p Data to the hash.
+void MD5::update(ArrayRef<uint8_t> Data) {
   MD5_u32plus saved_lo;
   unsigned long used, free;
-  const unsigned char *Ptr = Data.data();
+  const uint8_t *Ptr = Data.data();
   unsigned long Size = Data.size();
 
   saved_lo = lo;
@@ -208,17 +208,25 @@ void MD5::update(ArrayRef<unsigned char> Data) {
     memcpy(&buffer[used], Ptr, free);
     Ptr = Ptr + free;
     Size -= free;
-    body(ArrayRef<unsigned char>(buffer, 64));
+    body(ArrayRef<uint8_t>(buffer, 64));
   }
 
   if (Size >= 64) {
-    Ptr = body(ArrayRef<unsigned char>(Ptr, Size & ~(unsigned long) 0x3f));
+    Ptr = body(ArrayRef<uint8_t>(Ptr, Size & ~(unsigned long) 0x3f));
     Size &= 0x3f;
   }
 
   memcpy(buffer, Ptr, Size);
 }
 
+/// Add the bytes in the StringRef \p Str to the hash.
+// Note that this isn't a string and so this won't include any trailing NULL
+// bytes.
+void MD5::update(StringRef Str) {
+  ArrayRef<uint8_t> SVal((const uint8_t *)Str.data(), Str.size());
+  update(SVal);
+}
+
 /// \brief Finish the hash and place the resulting hash into \p result.
 /// \param result is assumed to be a minimum of 16-bytes in size.
 void MD5::final(MD5Result &result) {
@@ -232,7 +240,7 @@ void MD5::final(MD5Result &result) {
 
   if (free < 8) {
     memset(&buffer[used], 0, free);
-    body(ArrayRef<unsigned char>(buffer, 64));
+    body(ArrayRef<uint8_t>(buffer, 64));
     used = 0;
     free = 64;
   }
@@ -249,7 +257,7 @@ void MD5::final(MD5Result &result) {
   buffer[62] = hi >> 16;
   buffer[63] = hi >> 24;
 
-  body(ArrayRef<unsigned char>(buffer, 64));
+  body(ArrayRef<uint8_t>(buffer, 64));
 
   result[0] = a;
   result[1] = a >> 8;