提交 f2d5d615 编写于 作者: Y youngowlf

Use memmove instead of memcpy for overlapped memory replication (in unpacker).

上级 7b42c4b5
...@@ -81,7 +81,7 @@ public: ...@@ -81,7 +81,7 @@ public:
if (unpack_ok && remain_len > 0) if (unpack_ok && remain_len > 0)
{ {
auto pnext = std::next(msg_pos_can.back().first, msg_pos_can.back().second); auto pnext = std::next(msg_pos_can.back().first, msg_pos_can.back().second);
memcpy(&*std::begin(raw_buff), pnext, remain_len); //left behind unparsed data memmove(&*std::begin(raw_buff), pnext, remain_len); //left behind unparsed data
} }
//if unpacking failed, successfully parsed msgs will still returned via msg_can(sticky package), please note. //if unpacking failed, successfully parsed msgs will still returned via msg_can(sticky package), please note.
...@@ -405,7 +405,7 @@ public: ...@@ -405,7 +405,7 @@ public:
if (pnext == &*std::begin(raw_buff)) //we should have at least got one msg. if (pnext == &*std::begin(raw_buff)) //we should have at least got one msg.
return false; return false;
else if (remain_len > 0) else if (remain_len > 0)
memcpy(&*std::begin(raw_buff), pnext, remain_len); //left behind unparsed msg memmove(&*std::begin(raw_buff), pnext, remain_len); //left behind unparsed msg
return true; return true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册