diff --git a/modules/core/src/alloc.cpp b/modules/core/src/alloc.cpp index f6abeeb09837..517ffa7e3382 100644 --- a/modules/core/src/alloc.cpp +++ b/modules/core/src/alloc.cpp @@ -54,8 +54,7 @@ //#define OPENCV_ALLOC_ENABLE_STATISTICS - -#ifdef HAVE_POSIX_MEMALIGN +#if defined(HAVE_POSIX_MEMALIGN) || (__cplusplus >= 201703L) #include #elif defined HAVE_MALLOC_H #include @@ -130,6 +129,15 @@ void* fastMalloc_(size_t size) void* fastMalloc(size_t size) #endif { +#if __cplusplus >= 201703L + if (isAlignedAllocationEnabled()) + { + void* ptr = std::aligned_alloc(size, CV_MALLOC_ALIGN); + if(!ptr) + return OutOfMemoryError(size); + return ptr; + } +#endif #ifdef HAVE_POSIX_MEMALIGN if (isAlignedAllocationEnabled()) { @@ -172,7 +180,7 @@ void fastFree_(void* ptr) void fastFree(void* ptr) #endif { -#if defined HAVE_POSIX_MEMALIGN || defined HAVE_MEMALIGN +#if defined HAVE_POSIX_MEMALIGN || defined HAVE_MEMALIGN || (__cplusplus >= 201703L) if (isAlignedAllocationEnabled()) { free(ptr); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy