From: Alexander Alekhin Date: Mon, 30 Jul 2018 11:09:50 +0000 (+0300) Subject: core(ocl): do not split refcount operations / compare X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1^2~597^2~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e90e398e7a64f48757c3a0e365256aef69f80dd2;p=platform%2Fupstream%2Fopencv.git core(ocl): do not split refcount operations / compare - check result from CV_XADD() directly - decrease urefcount after unmap() call only --- diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp index f61126b..151c4ac 100644 --- a/modules/core/src/umatrix.cpp +++ b/modules/core/src/umatrix.cpp @@ -84,14 +84,11 @@ UMatData::~UMatData() allocatorFlags_ = 0; if (originalUMatData) { - UMatData* u = originalUMatData; - CV_XADD(&(u->urefcount), -1); - CV_XADD(&(u->refcount), -1); bool showWarn = false; - if (u->refcount == 0) + UMatData* u = originalUMatData; + bool zero_Ref = CV_XADD(&(u->refcount), -1) == 1; + if (zero_Ref) { - if (u->urefcount > 0) - showWarn = true; // simulate Mat::deallocate if (u->mapcount != 0) { @@ -102,7 +99,10 @@ UMatData::~UMatData() // we don't do "map", so we can't do "unmap" } } - if (u->refcount == 0 && u->urefcount == 0) // oops, we need to free resources + bool zero_URef = CV_XADD(&(u->urefcount), -1) == 1; + if (zero_Ref && !zero_URef) + showWarn = true; + if (zero_Ref && zero_URef) // oops, we need to free resources { showWarn = true; // simulate UMat::deallocate