123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //TTSPtr - [2020-04-13 11:57:47]
- #ifndef _TTSPTR_H_
- #define _TTSPTR_H_
- #include "common.h"
- /*
- 0016779E TTSPtr<TNMVert>::TTSPtr()
- 001677BE TTSPtr<TNMVert>::TTSPtr(TNMVert*)
- 00166E50 TTSPtr<TNMVert>::~TTSPtr()
- 00167840 TTSPtr<TNMVert>::operator=(TTSPtr<TNMVert> const&)
- 00168AFC TTSPtr<TNMVert>::Release()
- struct TNMVert {
- int field_0;
- int field_4;
- };
- TTSPtr 智能指针
- 外部指针不能重复绑定,否则会崩溃
- */
- template <typename T>
- class TTSPtr {
- public:
- //0016779E
- TTSPtr() {
- pT_0 = 0;
- pRef_4 = new int;
- *pRef_4 = 0;
- ++(*pRef_4);
- };
- //-------------------------------------------------------------------------------------------------
- //001677BE
- TTSPtr(T *pNode) {
- pT_0 = pNode;
- pRef_4 = new int;
- *pRef_4 = 0;
- ++(*pRef_4);
- };
- //-------------------------------------------------------------------------------------------------
- //00166E50 TTSPtr_TNMVert
- ~TTSPtr() {
- int dr1 = *pRef_4;
- dr1--;
- *pRef_4 = dr1;
- if (dr1 == 0) {
- if (pT_0)
- delete pT_0;
- //loc_166E66
- if (pRef_4)
- delete pRef_4;
- }
- //loc_166E6E
- };
- //-------------------------------------------------------------------------------------------------
- //00167840
- TTSPtr<T> &operator=(TTSPtr<T> const &other) {
- if (this != &other) {
- --(*pRef_4);
- if (*pRef_4 == 0) {
- if (pT_0)
- delete pT_0;
- if (pRef_4)
- delete pRef_4;
- }
- //loc_167864
- this->pT_0 = other.pT_0;
- this->pRef_4 = other.pRef_4;
- ++(*other.pRef_4);
- }
- //loc_167872
- return *this;
- };
- //-------------------------------------------------------------------------------------------------
- inline bool operator==(TTSPtr<T> const &other) { //合理的猜测这个函数是被inline
- if (pT_0 == other.pT_0) {
- return true;
- }
- return false;
- }
- //-------------------------------------------------------------------------------------------------
- //00168AFC
- void Release() {
- --(*pRef_4);
- if (*pRef_4 == 0) {
- if (pT_0)
- delete pT_0;
- if (pRef_4)
- delete pRef_4;
- }
- //loc_168B1A
- pT_0 = nullptr;
- pRef_4 = new int;
- *pRef_4 = 0;
- ++(*pRef_4);
- };
- //-------------------------------------------------------------------------------------------------
- T *pT_0;
- int *pRef_4;
- };
- #endif //_TTSPTR_H_
|