use native aligned malloc on windows
This commit is contained in:
parent
fad61c7c7d
commit
fbf8ea3858
1 changed files with 16 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#ifndef _MSC_VER
|
||||||
// http://stackoverflow.com/a/18137117
|
// http://stackoverflow.com/a/18137117
|
||||||
struct Aligned {
|
struct Aligned {
|
||||||
static void*
|
static void*
|
||||||
|
@ -20,3 +21,18 @@ struct Aligned {
|
||||||
delete[] mem;
|
delete[] mem;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
#include <malloc.h>
|
||||||
|
struct Aligned {
|
||||||
|
static void*
|
||||||
|
operator new(size_t sz) {
|
||||||
|
return _aligned_malloc(sz, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
operator delete(void* aligned, size_t sz)
|
||||||
|
{
|
||||||
|
_aligned_free(aligned);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue