PKGBUILDs/aur/par2cmdline/10-Pack-and-simplify-MD5Hash.patch
2011-06-09 17:56:14 -04:00

69 lines
1.4 KiB
Diff

--- a/md5.h
+++ b/md5.h
@@ -20,6 +20,13 @@
#ifndef __MD5_H__
#define __MD5_H__
+#ifdef WIN32
+#pragma pack(push, 1)
+#define PACKED
+#else
+#define PACKED __attribute__ ((packed))
+#endif
+
// This file defines the MD5Hash and MD5Context objects which are used
// to compute and manipulate the MD5 Hash values for a block of data.
@@ -35,12 +42,11 @@
// MD5 Hash value
-class MD5Hash
-{
-public:
- // Constructor does not initialise the value
- MD5Hash(void) {};
+struct MD5Hash;
+ostream& operator<<(ostream &s, const MD5Hash &hash);
+struct MD5Hash
+{
// Comparison operators
bool operator==(const MD5Hash &other) const;
bool operator!=(const MD5Hash &other) const;
@@ -54,13 +60,8 @@ public:
friend ostream& operator<<(ostream &s, const MD5Hash &hash);
string print(void) const;
- // Copy and assignment
- MD5Hash(const MD5Hash &other);
- MD5Hash& operator=(const MD5Hash &other);
-
-public:
u8 hash[16]; // 16 byte MD5 Hash value
-};
+} PACKED;
// Intermediate computation state
@@ -144,16 +145,9 @@ inline bool MD5Hash::operator<=(const MD5Hash &other) const
return !other.operator<(*this);
}
-inline MD5Hash::MD5Hash(const MD5Hash &other)
-{
- memcpy(&hash, &other.hash, sizeof(hash));
-}
-
-inline MD5Hash& MD5Hash::operator=(const MD5Hash &other)
-{
- memcpy(&hash, &other.hash, sizeof(hash));
-
- return *this;
-}
+#ifdef WIN32
+#pragma pack(pop)
+#endif
+#undef PACKED
#endif // __MD5_H__