| 25 | |
| 26 | namespace BinaryNinjaDebugger { |
| 27 | class DbgRefCountObject |
| 28 | { |
| 29 | //CORE_ALLOCATED_CLASS(RefCountObject) |
| 30 | |
| 31 | public: |
| 32 | std::atomic<int> m_refs; |
| 33 | DbgRefCountObject() : m_refs(0) {} |
| 34 | virtual ~DbgRefCountObject() {} |
| 35 | |
| 36 | virtual void AddRef() { m_refs.fetch_add(1); } |
| 37 | |
| 38 | virtual void Release() |
| 39 | { |
| 40 | if (m_refs.fetch_sub(1) == 1) |
| 41 | delete this; |
| 42 | } |
| 43 | |
| 44 | virtual void AddAPIRef() { AddRef(); } |
| 45 | |
| 46 | virtual void ReleaseAPIRef() { Release(); } |
| 47 | }; |
| 48 | |
| 49 | |
| 50 | template <class T> |
nothing calls this directly
no outgoing calls
no test coverage detected