diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2017-09-05 22:14:56 +0200 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2017-09-05 22:14:56 +0200 |
commit | a3c298e1d1f02634e87c7ba1746fd7e9ed444875 (patch) | |
tree | 0d8812791efe7a0926903305380dd4876eb0ac0e | |
parent | f231112cc4f0c1fe7f8bb937a49e4469157a2fa7 (diff) | |
download | minetest-a3c298e1d1f02634e87c7ba1746fd7e9ed444875.tar.gz minetest-a3c298e1d1f02634e87c7ba1746fd7e9ed444875.tar.bz2 minetest-a3c298e1d1f02634e87c7ba1746fd7e9ed444875.zip |
Use a Buffer instead of SharedBuffer in ConnectionCommand
This fixes #6373
-rw-r--r-- | src/network/connection.h | 2 | ||||
-rw-r--r-- | src/util/pointer.h | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/network/connection.h b/src/network/connection.h index d569722bf..5062b73d0 100644 --- a/src/network/connection.h +++ b/src/network/connection.h @@ -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; diff --git a/src/util/pointer.h b/src/util/pointer.h index efca62d2d..59b6f5216 100644 --- a/src/util/pointer.h +++ b/src/util/pointer.h @@ -168,6 +168,18 @@ public: /* 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(); |