aboutsummaryrefslogtreecommitdiff
path: root/src/protocol.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2021-05-13 08:44:34 +0100
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2021-05-13 12:42:21 +0100
commit1c9255c7dd2d4f12bfb508bcc8d123a6354d8842 (patch)
tree84a9005eeb275aead306fe277bbb25bb39a74448 /src/protocol.cpp
parent9c891b64ffd14bc8216dbd5eb60816043af265b6 (diff)
refactor: Replace memset calls with array initialization
Diffstat (limited to 'src/protocol.cpp')
-rw-r--r--src/protocol.cpp11
1 files changed, 1 insertions, 10 deletions
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 2f77ec18e6..2e70b41e4c 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -87,25 +87,16 @@ const static std::string allNetMessageTypes[] = {
};
const static std::vector<std::string> allNetMessageTypesVec(std::begin(allNetMessageTypes), std::end(allNetMessageTypes));
-CMessageHeader::CMessageHeader()
-{
- memset(pchMessageStart, 0, MESSAGE_START_SIZE);
- memset(pchCommand, 0, sizeof(pchCommand));
- memset(pchChecksum, 0, CHECKSUM_SIZE);
-}
-
CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn, const char* pszCommand, unsigned int nMessageSizeIn)
{
memcpy(pchMessageStart, pchMessageStartIn, MESSAGE_START_SIZE);
- // Copy the command name, zero-padding to COMMAND_SIZE bytes
+ // Copy the command name
size_t i = 0;
for (; i < COMMAND_SIZE && pszCommand[i] != 0; ++i) pchCommand[i] = pszCommand[i];
assert(pszCommand[i] == 0); // Assert that the command name passed in is not longer than COMMAND_SIZE
- for (; i < COMMAND_SIZE; ++i) pchCommand[i] = 0;
nMessageSize = nMessageSizeIn;
- memset(pchChecksum, 0, CHECKSUM_SIZE);
}
std::string CMessageHeader::GetCommand() const