1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Network cleanup (#6310)

* Move Connection threads to dedicated files + various cleanups

* ConnectionReceiveThread::processPacket now uses function pointer table to route MT packet types
* Various code style fixes

* Code style with clang-format

* Various SharedBuffer copy removal

* SharedBuffer cannot be copied anymore using Buffer
* Fix many SharedBuffer copy (thanks to delete operator)
This commit is contained in:
Loïc Blot 2017-08-25 15:53:56 +02:00 committed by GitHub
parent f6a33a1a7a
commit 3cea7a349a
11 changed files with 1670 additions and 1669 deletions

View file

@ -104,7 +104,6 @@ private:
/************************************************
* !!! W A R N I N G !!! *
* !!! A C H T U N G !!! *
* *
* This smart pointer class is NOT thread safe. *
* ONLY use in a single-threaded context! *
@ -134,7 +133,6 @@ public:
}
SharedBuffer(const SharedBuffer &buffer)
{
//std::cout<<"SharedBuffer(const SharedBuffer &buffer)"<<std::endl;
m_size = buffer.m_size;
data = buffer.data;
refcount = buffer.refcount;
@ -142,7 +140,6 @@ public:
}
SharedBuffer & operator=(const SharedBuffer & buffer)
{
//std::cout<<"SharedBuffer & operator=(const SharedBuffer & buffer)"<<std::endl;
if(this == &buffer)
return *this;
drop();
@ -171,19 +168,6 @@ 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();
@ -220,9 +204,3 @@ private:
unsigned int m_size;
unsigned int *refcount;
};
inline SharedBuffer<u8> SharedBufferFromString(const char *string)
{
SharedBuffer<u8> b((u8*)string, strlen(string)+1);
return b;
}