Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:51

0001 #ifndef VECCORE_UTILITIES_H
0002 #define VECCORE_UTILITIES_H
0003 
0004 #ifndef _MSC_VER
0005 
0006 #include <cstdlib>
0007 
0008 namespace vecCore {
0009 
0010 inline void *AlignedAlloc(size_t alignment, size_t size)
0011 {
0012   void *ptr = nullptr;
0013 
0014   if (posix_memalign(&ptr, alignment, size) == 0)
0015     return ptr;
0016 
0017   return nullptr;
0018 }
0019 
0020 inline void AlignedFree(void *ptr)
0021 {
0022   free(ptr);
0023 }
0024 
0025 }
0026 
0027 #else // _MSC_VER
0028 
0029 #include <malloc.h>
0030 
0031 namespace vecCore {
0032 
0033 inline void *AlignedAlloc(size_t alignment, size_t size)
0034 {
0035   return _aligned_malloc(size, alignment);
0036 }
0037 
0038 inline void AlignedFree(void *ptr)
0039 {
0040   _aligned_free(ptr);
0041 }
0042 
0043 }
0044 
0045 #endif // _MSC_VER
0046 
0047 #endif // VECCORE_UTILITIES_H