aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-09-04 02:03:39 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-09-04 02:27:04 +0200
commit1e4f87f5a13e34a457b537e9d13a212e6c5b754f (patch)
tree8b6199e305854d567e04dadfc0302ade2718ead9
parent8a41e1edd4d31d08b7360d7e5964c1c40a7aa1b6 (diff)
Use memcmp for uint256 equality/inequality
-rw-r--r--src/uint256.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/uint256.h b/src/uint256.h
index d1a822af0d..6bb9a59400 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -10,6 +10,7 @@
#include <stdexcept>
#include <stdint.h>
#include <string>
+#include <cstring>
#include <vector>
class uint_error : public std::runtime_error {
@@ -215,8 +216,8 @@ public:
friend inline const base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; }
friend inline const base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; }
friend inline const base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; }
- friend inline bool operator==(const base_uint& a, const base_uint& b) { return a.CompareTo(b) == 0; }
- friend inline bool operator!=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) != 0; }
+ friend inline bool operator==(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) == 0; }
+ friend inline bool operator!=(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) != 0; }
friend inline bool operator>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) > 0; }
friend inline bool operator<(const base_uint& a, const base_uint& b) { return a.CompareTo(b) < 0; }
friend inline bool operator>=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) >= 0; }