From 2040540e94669536755bd095d585779026474658 Mon Sep 17 00:00:00 2001 From: Fred Nicolson Date: Mon, 5 Mar 2018 10:37:09 +0000 Subject: [PATCH] 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. --- include/frnetlib/Packet.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/frnetlib/Packet.h b/include/frnetlib/Packet.h index 9525c73..ddb8cf2 100644 --- a/include/frnetlib/Packet.h +++ b/include/frnetlib/Packet.h @@ -82,7 +82,7 @@ namespace fr inline Packet &operator<<(const std::vector &vec) { //First store its length - *this << vec.size(); + *this << static_cast(vec.size()); //Now each of the elements for(const auto &iter : vec) @@ -99,7 +99,7 @@ namespace fr template inline Packet &operator>>(std::vector &vec) { - size_t length; + uint64_t length; //First extract the length *this >> length; @@ -568,7 +568,7 @@ namespace fr uint32_t length = htonl((uint32_t)buffer.size() - PACKET_HEADER_LENGTH); memcpy(&buffer[0], &length, sizeof(uint32_t)); - //Then a reference to the buffer + //Then return a reference to the buffer return buffer; }