Skip to content

Commit a3c298e

Browse files
committedSep 5, 2017
Use a Buffer instead of SharedBuffer in ConnectionCommand
This fixes #6373
1 parent f231112 commit a3c298e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
 

Diff for: ‎src/network/connection.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ struct ConnectionCommand
325325
Address address;
326326
u16 peer_id = PEER_ID_INEXISTENT;
327327
u8 channelnum = 0;
328-
SharedBuffer<u8> data;
328+
Buffer<u8> data;
329329
bool reliable = false;
330330
bool raw = false;
331331

Diff for: ‎src/util/pointer.h

+12
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ class SharedBuffer
168168
/*
169169
Copies whole buffer
170170
*/
171+
SharedBuffer(const Buffer<T> &buffer)
172+
{
173+
m_size = buffer.getSize();
174+
if (m_size != 0) {
175+
data = new T[m_size];
176+
memcpy(data, *buffer, buffer.getSize());
177+
}
178+
else
179+
data = NULL;
180+
refcount = new unsigned int;
181+
(*refcount) = 1;
182+
}
171183
~SharedBuffer()
172184
{
173185
drop();

0 commit comments

Comments
 (0)
Please sign in to comment.