Commit 032b6322 authored by Alexander Alekhin's avatar Alexander Alekhin

fix MatAllocator creation/destruction issues

parent b98a54fb
...@@ -222,10 +222,14 @@ public: ...@@ -222,10 +222,14 @@ public:
} }
}; };
static StdMatAllocator *mat_allocator = NULL;
MatAllocator* Mat::getStdAllocator() MatAllocator* Mat::getStdAllocator()
{ {
static StdMatAllocator allocator; if (mat_allocator == NULL)
return &allocator; {
mat_allocator = new StdMatAllocator();
}
return mat_allocator;
} }
void swap( Mat& a, Mat& b ) void swap( Mat& a, Mat& b )
......
...@@ -5160,10 +5160,15 @@ public: ...@@ -5160,10 +5160,15 @@ public:
MatAllocator* matStdAllocator; MatAllocator* matStdAllocator;
}; };
// This line should not force OpenCL runtime initialization! (don't put "new OpenCLAllocator()" here)
static MatAllocator *ocl_allocator = NULL;
MatAllocator* getOpenCLAllocator() MatAllocator* getOpenCLAllocator()
{ {
static MatAllocator * allocator = new OpenCLAllocator(); if (ocl_allocator == NULL)
return allocator; {
ocl_allocator = new OpenCLAllocator();
}
return ocl_allocator;
} }
///////////////////////////////////////////// Utility functions ///////////////////////////////////////////////// ///////////////////////////////////////////// Utility functions /////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment