Removed use of platform dependant type when dealing with vectors
Previously, fr::Packet would use 'size_t' for dealing with vector sizes. This is not ideal though, as the size of size_t is platform depenant, meaning that fr::Packet's sent on one computer might be incompatible with other systems.
This commit is contained in:
parent
addd1cf19b
commit
2040540e94
@ -82,7 +82,7 @@ namespace fr
|
|||||||
inline Packet &operator<<(const std::vector<T> &vec)
|
inline Packet &operator<<(const std::vector<T> &vec)
|
||||||
{
|
{
|
||||||
//First store its length
|
//First store its length
|
||||||
*this << vec.size();
|
*this << static_cast<uint64_t>(vec.size());
|
||||||
|
|
||||||
//Now each of the elements
|
//Now each of the elements
|
||||||
for(const auto &iter : vec)
|
for(const auto &iter : vec)
|
||||||
@ -99,7 +99,7 @@ namespace fr
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
inline Packet &operator>>(std::vector<T> &vec)
|
inline Packet &operator>>(std::vector<T> &vec)
|
||||||
{
|
{
|
||||||
size_t length;
|
uint64_t length;
|
||||||
|
|
||||||
//First extract the length
|
//First extract the length
|
||||||
*this >> length;
|
*this >> length;
|
||||||
@ -568,7 +568,7 @@ namespace fr
|
|||||||
uint32_t length = htonl((uint32_t)buffer.size() - PACKET_HEADER_LENGTH);
|
uint32_t length = htonl((uint32_t)buffer.size() - PACKET_HEADER_LENGTH);
|
||||||
memcpy(&buffer[0], &length, sizeof(uint32_t));
|
memcpy(&buffer[0], &length, sizeof(uint32_t));
|
||||||
|
|
||||||
//Then a reference to the buffer
|
//Then return a reference to the buffer
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user