diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-12-19 17:08:25 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-12-19 19:10:34 -0500 |
commit | 26ce92b3526430d4a40b2faccef4facb966d6a0a (patch) | |
tree | e23a92f6152c3abcf8cf3c42bf5a5b50ecc5dc42 /src/serialize.h | |
parent | bd846c0e565ca0db276cb6b7eac7763bebe19b84 (diff) |
Use std::numeric_limits<> for typesafe INT_MAX/etc
Diffstat (limited to 'src/serialize.h')
-rw-r--r-- | src/serialize.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/serialize.h b/src/serialize.h index df060fdd77..98b69aa228 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -189,8 +189,8 @@ template<typename Stream> inline void Unserialize(Stream& s, bool& a, int, int=0 inline unsigned int GetSizeOfCompactSize(uint64 nSize) { if (nSize < 253) return sizeof(unsigned char); - else if (nSize <= USHRT_MAX) return sizeof(unsigned char) + sizeof(unsigned short); - else if (nSize <= UINT_MAX) return sizeof(unsigned char) + sizeof(unsigned int); + else if (nSize <= std::numeric_limits<unsigned short>::max()) return sizeof(unsigned char) + sizeof(unsigned short); + else if (nSize <= std::numeric_limits<unsigned int>::max()) return sizeof(unsigned char) + sizeof(unsigned int); else return sizeof(unsigned char) + sizeof(uint64); } @@ -202,14 +202,14 @@ void WriteCompactSize(Stream& os, uint64 nSize) unsigned char chSize = nSize; WRITEDATA(os, chSize); } - else if (nSize <= USHRT_MAX) + else if (nSize <= std::numeric_limits<unsigned short>::max()) { unsigned char chSize = 253; unsigned short xSize = nSize; WRITEDATA(os, chSize); WRITEDATA(os, xSize); } - else if (nSize <= UINT_MAX) + else if (nSize <= std::numeric_limits<unsigned int>::max()) { unsigned char chSize = 254; unsigned int xSize = nSize; |