summaryrefslogtreecommitdiff
path: root/include/m_system_cpp.h
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-06-04 13:09:01 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-06-04 13:09:01 +0000
commit420403dedffee8a10336e450337d30e1f25336b2 (patch)
tree83cb1fa5841c10f70c82ecd8ab3e6ad01cbaec85 /include/m_system_cpp.h
parentebd9c68d49bb57f0c9aa3d242200ce3a3e4e2283 (diff)
code optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@16912 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'include/m_system_cpp.h')
-rw-r--r--include/m_system_cpp.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h
index 9ef15830bc..32c26db65c 100644
--- a/include/m_system_cpp.h
+++ b/include/m_system_cpp.h
@@ -21,6 +21,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
#ifndef M_SYSTEM_CPP_H__
#define M_SYSTEM_CPP_H__ 1
@@ -42,12 +43,14 @@ namespace std
template<class T> class mir_ptr
{
+protected:
T* data;
public:
__inline explicit mir_ptr() : data(NULL) {}
__inline explicit mir_ptr(T* _p) : data(_p) {}
__inline ~mir_ptr() { mir_free(data); }
+ __inline T* get() const { return data; }
__inline T* operator = (T* _p) { if (data) mir_free(data); data = _p; return data; }
__inline T* operator->() const { return data; }
__inline operator T*() const { return data; }
@@ -97,8 +100,8 @@ public:
__inline ~pass_ptrA() { zero(); }
__inline char* operator = (char *_p){ zero(); return mir_ptr::operator=(_p); }
__inline void zero()
- { char *_data = mir_ptr::operator char *();
- if (_data) SecureZeroMemory(_data, mir_strlen(_data));
+ {
+ if (data) SecureZeroMemory(data, mir_strlen(data));
}
};
@@ -110,8 +113,8 @@ public:
__inline ~pass_ptrW() { zero(); }
__inline WCHAR* operator = (WCHAR *_p){ zero(); return mir_ptr::operator=(_p); }
__inline void zero()
- { WCHAR *_data = mir_ptr::operator WCHAR *();
- if (_data) SecureZeroMemory(_data, mir_wstrlen(_data)*sizeof(WCHAR));
+ {
+ if (data) SecureZeroMemory(data, mir_wstrlen(data)*sizeof(WCHAR));
}
};