1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Clarified default allocator interface.

Conflicts:
	modules/core/src/matrix.cpp
This commit is contained in:
Dan Moodie
2015-11-30 15:45:48 -05:00
committed by Dan
parent 5d5cf32e22
commit 4f373a4284
3 changed files with 28 additions and 11 deletions
+20 -3
View File
@@ -218,10 +218,27 @@ public:
delete u;
}
};
namespace
{
MatAllocator* g_matAllocator = nullptr;
}
MatAllocator* Mat::getDefaultAllocator()
{
if (g_matAllocator == nullptr)
{
g_matAllocator = getStdAllocator();
}
return g_matAllocator;
}
void Mat::setDefaultAllocator(MatAllocator* allocator)
{
g_matAllocator = allocator;
}
MatAllocator* Mat::getStdAllocator()
{
CV_SINGLETON_LAZY_INIT(MatAllocator, new StdMatAllocator())
CV_SINGLETON_LAZY_INIT(MatAllocator, new StdMatAllocator())
}
void swap( Mat& a, Mat& b )
@@ -388,7 +405,7 @@ void Mat::create(int d, const int* _sizes, int _type)
if( total() > 0 )
{
MatAllocator *a = allocator, *a0 = getStdAllocator();
MatAllocator *a = allocator, *a0 = getDefaultAllocator();
#ifdef HAVE_TGPU
if( !a || a == tegra::getAllocator() )
a = tegra::getAllocator(d, _sizes, _type);
@@ -426,7 +443,7 @@ void Mat::copySize(const Mat& m)
void Mat::deallocate()
{
if(u)
(u->currAllocator ? u->currAllocator : allocator ? allocator : getStdAllocator())->unmap(u);
(u->currAllocator ? u->currAllocator : allocator ? allocator : getDefaultAllocator())->unmap(u);
u = NULL;
}