mirror of https://github.com/OpenTTD/OpenTTD
Fix d9a04ba446: Ensure MD5Hash is initialized. (#10876)
Not all instances need to be initialized as often they are copied or written to, but doing all ensures no surprises. Move the ^= operator to MD5Hash while we're at it.pull/10881/head
parent
ba11467c02
commit
101e4e54a1
|
@ -57,20 +57,20 @@
|
||||||
static const size_t MD5_HASH_BYTES = 16;
|
static const size_t MD5_HASH_BYTES = 16;
|
||||||
|
|
||||||
/** Container for storing a MD5 hash/checksum/digest. */
|
/** Container for storing a MD5 hash/checksum/digest. */
|
||||||
using MD5Hash = std::array<byte, MD5_HASH_BYTES>;
|
struct MD5Hash : std::array<byte, MD5_HASH_BYTES> {
|
||||||
|
MD5Hash() : std::array<byte, MD5_HASH_BYTES>{} {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exclusively-or one hash into another hash.
|
* Exclusively-or the given hash into this hash.
|
||||||
* @param lhs The hash to exclusively-or into.
|
* @param other The other hash.
|
||||||
* @param rhs The hash to exclusively-or with.
|
* @return Reference to this hash.
|
||||||
* @return Reference to \c lhs hash.
|
|
||||||
*/
|
*/
|
||||||
inline MD5Hash &operator^=(MD5Hash &lhs, const MD5Hash &rhs)
|
MD5Hash &operator^=(const MD5Hash &other)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < lhs.size(); i++) lhs[i] ^= rhs[i];
|
for (size_t i = 0; i < size(); i++) this->operator[](i) ^= other[i];
|
||||||
return lhs;
|
return *this;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct Md5 {
|
struct Md5 {
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue