summaryrefslogtreecommitdiff
path: root/src/VBox/NetworkServices/NetLib/shared_ptr.h
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2014-01-24 08:23:12 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2014-01-24 08:23:12 +0000
commit94096689d8d1642558b545d8f5a9c6896cf6562b (patch)
tree8ee22465dbade02779827f75e65411d22ad0131e /src/VBox/NetworkServices/NetLib/shared_ptr.h
parent784ad647e54153a9b8a030ee773be8c0fcd27a38 (diff)
downloadVirtualBox-svn-94096689d8d1642558b545d8f5a9c6896cf6562b.tar.gz
spaces
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@50213 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/NetworkServices/NetLib/shared_ptr.h')
-rw-r--r--src/VBox/NetworkServices/NetLib/shared_ptr.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/VBox/NetworkServices/NetLib/shared_ptr.h b/src/VBox/NetworkServices/NetLib/shared_ptr.h
index 8bdfccec16c..ad892de79b6 100644
--- a/src/VBox/NetworkServices/NetLib/shared_ptr.h
+++ b/src/VBox/NetworkServices/NetLib/shared_ptr.h
@@ -2,10 +2,10 @@
#define __SHARED_PTR_H__
#ifdef __cplusplus
-template<typename T>
+template<typename T>
class SharedPtr
{
- struct imp
+ struct imp
{
imp(T *pTrg = NULL, int cnt = 1): ptr(pTrg),refcnt(cnt){}
~imp() { if (ptr) delete ptr;}
@@ -14,13 +14,13 @@ class SharedPtr
int refcnt;
};
-
+
public:
SharedPtr(T *t = NULL):p(NULL)
{
p = new imp(t);
}
-
+
~SharedPtr()
{
p->refcnt--;
@@ -39,9 +39,9 @@ class SharedPtr
const SharedPtr& operator= (const SharedPtr& rhs)
{
if (p == rhs.p) return *this;
-
+
p->refcnt--;
- if (p->refcnt == 0)
+ if (p->refcnt == 0)
delete p;
p = rhs.p;
@@ -56,13 +56,13 @@ class SharedPtr
return p->ptr;
}
-
+
T *operator->()
{
return p->ptr;
}
-
+
const T*operator->() const
{
return p->ptr;
@@ -78,4 +78,5 @@ class SharedPtr
imp *p;
};
#endif
+
#endif