best cross-platform method to get aligned memory

前端 未结 5 2022
梦谈多话
梦谈多话 2020-12-04 14:56

Here is the code I normally use to get aligned memory with Visual Studio and GCC

inline void* aligned_malloc(size_t size, size_t align) {
    void *result;
          


        
5条回答
  •  独厮守ぢ
    2020-12-04 15:27

    Here are my 2 cents:

    temp = new unsigned char*[num];
    AlignedBuffers = new unsigned char*[num];
    for (int i = 0; i((reinterpret_cast
                            (temp[i% num]) + 15) & ~15);// 16 bit alignment in preperation for SSE
    }
    

提交回复
热议问题