X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fconnection.cpp;h=b9c5d2ac8bac413c1264ac6746e873fca0c471e7;hb=8492796a5c45787810aad7fe08fc63cadc0c96b5;hp=cdf8cd3b49cd87bc38daec980d0285514525ed76;hpb=c349708eab121c60a0872b38160599c3ab9568cf;p=oweals%2Fminetest.git diff --git a/src/connection.cpp b/src/connection.cpp index cdf8cd3b4..b9c5d2ac8 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -670,7 +670,7 @@ void Connection::receive() // TODO: We can not know how many layers of header there are. // For now, just assume there are no other than the base headers. u32 packet_maxsize = datasize + BASE_HEADER_SIZE; - Buffer packetdata(packet_maxsize); + SharedBuffer packetdata(packet_maxsize); bool single_wait_done = false; @@ -1577,7 +1577,7 @@ void Connection::Disconnect() putCommand(c); } -u32 Connection::Receive(u16 &peer_id, u8 *data, u32 datasize) +u32 Connection::Receive(u16 &peer_id, SharedBuffer &data) { for(;;){ ConnectionEvent e = waitEvent(m_bc_receive_timeout); @@ -1589,7 +1589,7 @@ u32 Connection::Receive(u16 &peer_id, u8 *data, u32 datasize) throw NoIncomingDataException("No incoming data"); case CONNEVENT_DATA_RECEIVED: peer_id = e.peer_id; - memcpy(data, *e.data, e.data.getSize()); + data = SharedBuffer(e.data); return e.data.getSize(); case CONNEVENT_PEER_ADDED: { Peer tmp(e.peer_id, e.address);