Skip to content

Commit

Permalink
Use a Buffer instead of SharedBuffer in ConnectionCommand
Browse files Browse the repository at this point in the history
This fixes #6373
  • Loading branch information
nerzhul committed Sep 5, 2017
1 parent f231112 commit a3c298e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/network/connection.h
Expand Up @@ -325,7 +325,7 @@ struct ConnectionCommand
Address address;
u16 peer_id = PEER_ID_INEXISTENT;
u8 channelnum = 0;
SharedBuffer<u8> data;
Buffer<u8> data;
bool reliable = false;
bool raw = false;

Expand Down
12 changes: 12 additions & 0 deletions src/util/pointer.h
Expand Up @@ -168,6 +168,18 @@ class SharedBuffer
/*
Copies whole buffer
*/
SharedBuffer(const Buffer<T> &buffer)
{
m_size = buffer.getSize();
if (m_size != 0) {
data = new T[m_size];
memcpy(data, *buffer, buffer.getSize());
}
else
data = NULL;
refcount = new unsigned int;
(*refcount) = 1;
}
~SharedBuffer()
{
drop();
Expand Down

0 comments on commit a3c298e

Please sign in to comment.