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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user