summaryrefslogtreecommitdiff
authoralwin <alwin>2004-03-11 22:52:07 (UTC)
committer alwin <alwin>2004-03-11 22:52:07 (UTC)
commit83b7f42d5f93e1657705584d3d626b8d8fde28ac (patch) (unidiff)
tree6510078c79ae4b5f1fb2fdcfb71ad5a1247c8ad0
parent31fe5681a49cbcf291abf755ee5f2f2fb1e4a582 (diff)
downloadopie-83b7f42d5f93e1657705584d3d626b8d8fde28ac.zip
opie-83b7f42d5f93e1657705584d3d626b8d8fde28ac.tar.gz
opie-83b7f42d5f93e1657705584d3d626b8d8fde28ac.tar.bz2
*sigh* forgot to test before first checkin. sorry.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/osmart_pointer.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opiecore/osmart_pointer.h b/libopie2/opiecore/osmart_pointer.h
index a362a60..2a2518f 100644
--- a/libopie2/opiecore/osmart_pointer.h
+++ b/libopie2/opiecore/osmart_pointer.h
@@ -70,52 +70,52 @@ template<class T> class osmart_pointer {
70 * this object must contain Incr(), Decr() and Shared() 70 * this object must contain Incr(), Decr() and Shared()
71 * methode as public members. The best way is, that it will be a child 71 * methode as public members. The best way is, that it will be a child
72 * class of RefCount 72 * class of RefCount
73 */ 73 */
74 T *ptr; 74 T *ptr;
75public: 75public:
76 //! standart constructor 76 //! standart constructor
77 osmart_pointer() { ptr = NULL; } 77 osmart_pointer() { ptr = NULL; }
78 //! standart destructor 78 //! standart destructor
79 /*! 79 /*!
80 * release the reference, if it were the last reference, destroys 80 * release the reference, if it were the last reference, destroys
81 * ptr 81 * ptr
82 */ 82 */
83 ~osmart_pointer() 83 ~osmart_pointer()
84 { 84 {
85 if (ptr){ 85 if (ptr){
86 ptr->Decr(); 86 ptr->Decr();
87 if (!ptr->Shared()) 87 if (!ptr->Shared())
88 delete ptr; 88 delete ptr;
89 } 89 }
90 } 90 }
91 //! construction 91 //! construction
92 osmart_pointer(T* t) { if (ptr = t) ptr->Incr(); } 92 osmart_pointer(T* t) { if (ptr = t) ptr->Incr(); }
93 //! Pointer copy 93 //! Pointer copy
94 osmart_pointer(const smart_pointer<T>& p) 94 osmart_pointer(const osmart_pointer<T>& p)
95 { if (ptr = p.ptr) ptr->Incr(); } 95 { if (ptr = p.ptr) ptr->Incr(); }
96 //! pointer copy by assignment 96 //! pointer copy by assignment
97 osmart_pointer<T>& operator= (const smart_pointer<T>& p) 97 osmart_pointer<T>& operator= (const osmart_pointer<T>& p)
98 { 98 {
99 // already same: nothing to do 99 // already same: nothing to do
100 if (ptr == p.ptr) return *this; 100 if (ptr == p.ptr) return *this;
101 // decouple reference 101 // decouple reference
102 if (ptr) { ptr->Decr(); if (!ptr->Shared()) delete ptr; } 102 if (ptr) { ptr->Decr(); if (!ptr->Shared()) delete ptr; }
103 // establish new reference 103 // establish new reference
104 if (ptr = p.ptr) ptr->Incr(); 104 if (ptr = p.ptr) ptr->Incr();
105 return *this; 105 return *this;
106 } 106 }
107 osmart_pointer<T>& operator= (T*p) 107 osmart_pointer<T>& operator= (T*p)
108 { 108 {
109 if (ptr==p)return *this; 109 if (ptr==p)return *this;
110 if (ptr) { 110 if (ptr) {
111 ptr->Decr(); 111 ptr->Decr();
112 if (!ptr->Shared()) delete ptr; 112 if (!ptr->Shared()) delete ptr;
113 } 113 }
114 if (ptr=p) ptr->Incr(); 114 if (ptr=p) ptr->Incr();
115 return *this; 115 return *this;
116 } 116 }
117 117
118 //! cast to conventional pointer 118 //! cast to conventional pointer
119 operator T* () const { return ptr; } 119 operator T* () const { return ptr; }
120 120
121 //! deref: fails for NULL pointer 121 //! deref: fails for NULL pointer