From f91f55927e2fcee80d407b4501aa1f705e39e8da Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 29 Jan 2014 17:37:52 +0400 Subject: [PATCH] fix memory management problem --- modules/core/include/opencv2/core/ocl.hpp | 3 +++ modules/core/src/ocl.cpp | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp index 850a2e60e..3b790af98 100644 --- a/modules/core/include/opencv2/core/ocl.hpp +++ b/modules/core/include/opencv2/core/ocl.hpp @@ -561,6 +561,9 @@ public: explicit PlatformInfo2(void* id); ~PlatformInfo2(); + PlatformInfo2(const PlatformInfo2& i); + PlatformInfo2& operator =(const PlatformInfo2& i); + String name() const; String vendor() const; String version() const; diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 1a2714d05..d1e13a8a3 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -3707,6 +3707,26 @@ PlatformInfo2::~PlatformInfo2() p->release(); } +PlatformInfo2::PlatformInfo2(const PlatformInfo2& i) +{ + if (i.p) + i.p->addref(); + this->p = i.p; +} + +PlatformInfo2& PlatformInfo2::operator =(const PlatformInfo2& i) +{ + if (i.p != this->p) + { + if (i.p) + i.p->addref(); + if (this->p) + this->p->release(); + this->p = i.p; + } + return *this; +} + int PlatformInfo2::deviceNumber() const { return p ? (int)p->devices.size() : 0;