diff options
author | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2014-01-24 08:23:12 +0000 |
---|---|---|
committer | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2014-01-24 08:23:12 +0000 |
commit | 94096689d8d1642558b545d8f5a9c6896cf6562b (patch) | |
tree | 8ee22465dbade02779827f75e65411d22ad0131e /src/VBox/NetworkServices/NetLib/shared_ptr.h | |
parent | 784ad647e54153a9b8a030ee773be8c0fcd27a38 (diff) | |
download | VirtualBox-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.h | 17 |
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 |