Changed Get64(.) to GetLow64()

The function Get64(.) has a bug in case the width is not divisible by 64.
Since it is only ever used as Get64(0) this simply changes it to this
special case. Additionally, an assert is added, and a cast to prevent
a compiler error.
This commit is contained in:
Thomas Holenstein
2013-12-21 16:50:49 +01:00
parent 6e7792003b
commit e85e19be06
2 changed files with 8 additions and 7 deletions

View File

@@ -203,7 +203,7 @@ public:
{
// prefix operator
int i = 0;
while (--pn[i] == -1 && i < WIDTH-1)
while (--pn[i] == (uint32_t)-1 && i < WIDTH-1)
i++;
return *this;
}
@@ -370,9 +370,10 @@ public:
return sizeof(pn);
}
uint64_t Get64(int n=0) const
uint64_t GetLow64() const
{
return pn[2*n] | (uint64_t)pn[2*n+1] << 32;
assert(WIDTH >= 2);
return pn[0] | (uint64_t)pn[1] << 32;
}
// unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const