MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / DSCRef

Class DSCRef

view/sharedcache/api/sharedcacheapi.h:90–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88
89template <class T>
90class DSCRef
91{
92 T* m_obj;
93#ifdef BN_REF_COUNT_DEBUG
94 void* m_assignmentTrace = nullptr;
95#endif
96
97public:
98 DSCRef() : m_obj(NULL) {}
99
100 DSCRef(T* obj) : m_obj(obj)
101 {
102 if (m_obj)
103 {
104 m_obj->AddRef();
105#ifdef BN_REF_COUNT_DEBUG
106 m_assignmentTrace = BNRegisterObjectRefDebugTrace(typeid(T).name());
107#endif
108 }
109 }
110
111 DSCRef(const DSCRef<T>& obj) : m_obj(obj.m_obj)
112 {
113 if (m_obj)
114 {
115 m_obj->AddRef();
116#ifdef BN_REF_COUNT_DEBUG
117 m_assignmentTrace = BNRegisterObjectRefDebugTrace(typeid(T).name());
118#endif
119 }
120 }
121
122 DSCRef(DSCRef<T>&& other) : m_obj(other.m_obj)
123 {
124 other.m_obj = 0;
125#ifdef BN_REF_COUNT_DEBUG
126 m_assignmentTrace = other.m_assignmentTrace;
127#endif
128 }
129
130 ~DSCRef()
131 {
132 if (m_obj)
133 {
134 m_obj->Release();
135#ifdef BN_REF_COUNT_DEBUG
136 BNUnregisterObjectRefDebugTrace(typeid(T).name(), m_assignmentTrace);
137#endif
138 }
139 }
140
141 DSCRef<T>& operator=(const BinaryNinja::Ref<T>& obj)
142 {
143#ifdef BN_REF_COUNT_DEBUG
144 if (m_obj)
145 BNUnregisterObjectRefDebugTrace(typeid(T).name(), m_assignmentTrace);
146 if (obj.m_obj)
147 m_assignmentTrace = BNRegisterObjectRefDebugTrace(typeid(T).name());

Callers

nothing calls this directly

Calls 3

nameMethod · 0.45
AddRefMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected