Skip to content

Commit 718121d

Browse files
committedJun 5, 2017
Remove SharedPtr, it's not used and will be never used, we use C++11
1 parent bfacfc2 commit 718121d

File tree

2 files changed

+0
-76
lines changed

2 files changed

+0
-76
lines changed
 

‎src/treegen.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ void make_tree(MMVManip &vmanip, v3s16 p0,
5757
p1.Y -= 1;
5858

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

782781
VoxelArea leaves_a(v3s16(-3, -6, -3), v3s16(3, 3, 3));
783-
//SharedPtr<u8> leaves_d(new u8[leaves_a.getVolume()]);
784782
Buffer<u8> leaves_d(leaves_a.getVolume());
785783
for (s32 i = 0; i < leaves_a.getVolume(); i++)
786784
leaves_d[i] = 0;

‎src/util/pointer.h

-74
Original file line numberDiff line numberDiff line change
@@ -24,80 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2424
#include "../debug.h" // For assert()
2525
#include <cstring>
2626

27-
template <typename T>
28-
class SharedPtr
29-
{
30-
public:
31-
SharedPtr(T *t=NULL)
32-
{
33-
refcount = new int;
34-
*refcount = 1;
35-
ptr = t;
36-
}
37-
SharedPtr(SharedPtr<T> &t)
38-
{
39-
//*this = t;
40-
drop();
41-
refcount = t.refcount;
42-
(*refcount)++;
43-
ptr = t.ptr;
44-
}
45-
~SharedPtr()
46-
{
47-
drop();
48-
}
49-
SharedPtr<T> & operator=(T *t)
50-
{
51-
drop();
52-
refcount = new int;
53-
*refcount = 1;
54-
ptr = t;
55-
return *this;
56-
}
57-
SharedPtr<T> & operator=(SharedPtr<T> &t)
58-
{
59-
drop();
60-
refcount = t.refcount;
61-
(*refcount)++;
62-
ptr = t.ptr;
63-
return *this;
64-
}
65-
T* operator->()
66-
{
67-
return ptr;
68-
}
69-
T & operator*()
70-
{
71-
return *ptr;
72-
}
73-
bool operator!=(T *t)
74-
{
75-
return ptr != t;
76-
}
77-
bool operator==(T *t)
78-
{
79-
return ptr == t;
80-
}
81-
T & operator[](unsigned int i)
82-
{
83-
return ptr[i];
84-
}
85-
private:
86-
void drop()
87-
{
88-
assert((*refcount) > 0);
89-
(*refcount)--;
90-
if(*refcount == 0)
91-
{
92-
delete refcount;
93-
if(ptr != NULL)
94-
delete ptr;
95-
}
96-
}
97-
T *ptr;
98-
int *refcount;
99-
};
100-
10127
template <typename T>
10228
class Buffer
10329
{

0 commit comments

Comments
 (0)
Please sign in to comment.