From ee72f8df7139a0bb960d289a81c65641882d0db2 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Fri, 2 Aug 2019 12:04:19 -0400 Subject: Add move constructors to Ref objects --- binaryninjaapi.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index e4af4672..29f7c3b1 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -241,6 +241,14 @@ namespace BinaryNinja } } + Ref(Ref&& other) : m_obj(other.m_obj) + { + other.m_obj = 0; +#ifdef BN_REF_COUNT_DEBUG + m_assignmentTrace = other.m_assignmentTrace; +#endif + } + ~Ref() { if (m_obj) @@ -269,6 +277,22 @@ namespace BinaryNinja return *this; } + Ref& operator=(Ref&& other) + { + if (this != &other) + { + if (!m_obj) + m_obj = other.m_obj; + else if (m_obj != other.m_obj) + { + m_obj->Release(); + m_obj = other.m_obj; + } + other.m_obj = 0; + } + return *this; + } + Ref& operator=(T* obj) { #ifdef BN_REF_COUNT_DEBUG -- cgit v1.3.1