From a35a5e997900e18444efd02a859bc505a16af2d3 Mon Sep 17 00:00:00 2001 From: scott snyder <scott.snyder@cern.ch> Date: Mon, 19 Mar 2018 16:30:05 +0100 Subject: [PATCH] FourMom: Coverity 113518. Coverity warning: Add move ctor/op to DeepCopyPointer. Former-commit-id: b557d42390f329e9787deb1423e253f9bd6651e2 --- Event/FourMom/FourMom/DeepCopyPointer.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Event/FourMom/FourMom/DeepCopyPointer.h b/Event/FourMom/FourMom/DeepCopyPointer.h index 091da12c909..f2fd0a9d2f5 100644 --- a/Event/FourMom/FourMom/DeepCopyPointer.h +++ b/Event/FourMom/FourMom/DeepCopyPointer.h @@ -25,6 +25,12 @@ public: if (other.m_theData) m_theData = new T( *other); else m_theData = 0; } + DeepCopyPointer (DeepCopyPointer&& other) + { + m_theData = other.m_theData; + other.m_theData = nullptr; + } + ~DeepCopyPointer() { delete m_theData;} DeepCopyPointer& operator=( const DeepCopyPointer& other) { @@ -35,6 +41,15 @@ public: return *this; } + DeepCopyPointer& operator=( DeepCopyPointer&& other) { + if ( this != &other && m_theData != other.m_theData) { + delete m_theData; + m_theData = other.m_theData; + other.m_theData = nullptr; + } + return *this; + } + T* get() { return m_theData; } const T* get() const { return m_theData; } -- GitLab