add windows native aligned malloc + unit test case
* implements https://github.com/opencv/opencv/issues/19147 * CAUTION: this PR will only functions safely in the 4+ branches that already include PR 19029 * CAUTION: this PR requires thread-safe startup of the alloc.cpp translation unit as implemented in PR 19029
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
#include <cmath>
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@@ -783,5 +784,18 @@ TEST(Core_Check, testSize_1)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Core_Allocation, alignedAllocation)
|
||||
{
|
||||
// iterate from size=1 to approximate byte size of 8K 32bpp image buffer
|
||||
for (int i = 0; i < 200; i++) {
|
||||
const size_t size = static_cast<size_t>(std::pow(1.091, (double)i));
|
||||
void * const buf = cv::fastMalloc(size);
|
||||
ASSERT_NE((uintptr_t)0, (uintptr_t)buf)
|
||||
<< "failed to allocate memory";
|
||||
ASSERT_EQ((uintptr_t)0, (uintptr_t)buf % CV_MALLOC_ALIGN)
|
||||
<< "memory not aligned to " << CV_MALLOC_ALIGN;
|
||||
cv::fastFree(buf);
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user