From 420403dedffee8a10336e450337d30e1f25336b2 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sat, 4 Jun 2016 13:09:01 +0000 Subject: code optimization git-svn-id: http://svn.miranda-ng.org/main/trunk@16912 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_system_cpp.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'include/m_system_cpp.h') 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 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)); } }; -- cgit v1.2.3