1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Set and check allocator pointer for all cv::Mat instances.

This commit is contained in:
Alexander Smorkalov
2024-08-01 10:57:19 +03:00
parent 2a333a6c86
commit a15cd4b63d
2 changed files with 146 additions and 4 deletions
+2 -4
View File
@@ -692,16 +692,13 @@ void Mat::create(int d, const int* _sizes, int _type)
if( total() > 0 )
{
MatAllocator *a = allocator, *a0 = getDefaultAllocator();
#ifdef HAVE_TGPU
if( !a || a == tegra::getAllocator() )
a = tegra::getAllocator(d, _sizes, _type);
#endif
if(!a)
a = a0;
try
{
u = a->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT);
CV_Assert(u != 0);
allocator = a;
}
catch (...)
{
@@ -709,6 +706,7 @@ void Mat::create(int d, const int* _sizes, int _type)
throw;
u = a0->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT);
CV_Assert(u != 0);
allocator = a0;
}
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );
}