diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp index baea2bed..053fa4eb 100644 --- a/src/SFML/Network/Packet.cpp +++ b/src/SFML/Network/Packet.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace sf @@ -404,9 +405,7 @@ Packet& Packet::operator <<(double data) Packet& Packet::operator <<(const char* data) { // First insert string length - Uint32 length = 0; - for (const char* c = data; *c != '\0'; ++c) - ++length; + Uint32 length = std::strlen(data); *this << length; // Then insert characters @@ -425,9 +424,7 @@ Packet& Packet::operator <<(const std::string& data) // Then insert characters if (length > 0) - { append(data.c_str(), length * sizeof(std::string::value_type)); - } return *this; } @@ -437,9 +434,7 @@ Packet& Packet::operator <<(const std::string& data) Packet& Packet::operator <<(const wchar_t* data) { // First insert string length - Uint32 length = 0; - for (const wchar_t* c = data; *c != L'\0'; ++c) - ++length; + Uint32 length = std::wcslen(data); *this << length; // Then insert characters