Merge pull request #2218 from alalek:fix_defects_code_coverity

This commit is contained in:
Andrey Pavlenko
2014-01-31 19:23:01 +04:00
committed by OpenCV Buildbot
6 changed files with 33 additions and 6 deletions

View File

@@ -3691,6 +3691,7 @@ struct PlatformInfo2::Impl
{
Impl(void* id)
{
refcount = 1;
handle = *(cl_platform_id*)id;
getDevices(devices, handle);
}
@@ -3724,6 +3725,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;
@@ -3731,7 +3752,7 @@ int PlatformInfo2::deviceNumber() const
void PlatformInfo2::getDevice(Device& device, int d) const
{
CV_Assert(d < (int)p->devices.size() );
CV_Assert(p && d < (int)p->devices.size() );
if(p)
device.set(p->devices[d]);
}