Remove SharedPtr, it's not used and will be never used, we use C++11

This commit is contained in:
Loic Blot 2017-06-05 09:36:13 +02:00
parent bfacfc2062
commit 718121df91
No known key found for this signature in database
GPG Key ID: EFAA458E8C153987
2 changed files with 0 additions and 76 deletions

@ -57,7 +57,6 @@ void make_tree(MMVManip &vmanip, v3s16 p0,
p1.Y -= 1; p1.Y -= 1;
VoxelArea leaves_a(v3s16(-2, -1, -2), v3s16(2, 2, 2)); VoxelArea leaves_a(v3s16(-2, -1, -2), v3s16(2, 2, 2));
//SharedPtr<u8> leaves_d(new u8[leaves_a.getVolume()]);
Buffer<u8> leaves_d(leaves_a.getVolume()); Buffer<u8> leaves_d(leaves_a.getVolume());
for (s32 i = 0; i < leaves_a.getVolume(); i++) for (s32 i = 0; i < leaves_a.getVolume(); i++)
leaves_d[i] = 0; leaves_d[i] = 0;
@ -780,7 +779,6 @@ void make_pine_tree(MMVManip &vmanip, v3s16 p0, INodeDefManager *ndef, s32 seed)
p1.Y -= 1; p1.Y -= 1;
VoxelArea leaves_a(v3s16(-3, -6, -3), v3s16(3, 3, 3)); VoxelArea leaves_a(v3s16(-3, -6, -3), v3s16(3, 3, 3));
//SharedPtr<u8> leaves_d(new u8[leaves_a.getVolume()]);
Buffer<u8> leaves_d(leaves_a.getVolume()); Buffer<u8> leaves_d(leaves_a.getVolume());
for (s32 i = 0; i < leaves_a.getVolume(); i++) for (s32 i = 0; i < leaves_a.getVolume(); i++)
leaves_d[i] = 0; leaves_d[i] = 0;

@ -24,80 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "../debug.h" // For assert() #include "../debug.h" // For assert()
#include <cstring> #include <cstring>
template <typename T>
class SharedPtr
{
public:
SharedPtr(T *t=NULL)
{
refcount = new int;
*refcount = 1;
ptr = t;
}
SharedPtr(SharedPtr<T> &t)
{
//*this = t;
drop();
refcount = t.refcount;
(*refcount)++;
ptr = t.ptr;
}
~SharedPtr()
{
drop();
}
SharedPtr<T> & operator=(T *t)
{
drop();
refcount = new int;
*refcount = 1;
ptr = t;
return *this;
}
SharedPtr<T> & operator=(SharedPtr<T> &t)
{
drop();
refcount = t.refcount;
(*refcount)++;
ptr = t.ptr;
return *this;
}
T* operator->()
{
return ptr;
}
T & operator*()
{
return *ptr;
}
bool operator!=(T *t)
{
return ptr != t;
}
bool operator==(T *t)
{
return ptr == t;
}
T & operator[](unsigned int i)
{
return ptr[i];
}
private:
void drop()
{
assert((*refcount) > 0);
(*refcount)--;
if(*refcount == 0)
{
delete refcount;
if(ptr != NULL)
delete ptr;
}
}
T *ptr;
int *refcount;
};
template <typename T> template <typename T>
class Buffer class Buffer
{ {