fix msvc build
This commit is contained in:
parent
5317106d81
commit
8e66d78ef0
@ -4,11 +4,16 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
struct AlignedDeleter {
|
struct AlignedDeleter {
|
||||||
void operator()(void* p) const {
|
void operator()(void* p) const {
|
||||||
|
#if defined(_WIN32)
|
||||||
|
_aligned_free(p);
|
||||||
|
#else
|
||||||
std::free(p);
|
std::free(p);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -42,7 +47,11 @@ namespace util {
|
|||||||
|
|
||||||
void allocateNew() {
|
void allocateNew() {
|
||||||
std::unique_ptr<void, AlignedDeleter> ptr(
|
std::unique_ptr<void, AlignedDeleter> ptr(
|
||||||
|
#if defined(_WIN32)
|
||||||
|
_aligned_malloc(sizeof(T), alignof(T));
|
||||||
|
#else
|
||||||
std::aligned_alloc(alignof(T), sizeof(T))
|
std::aligned_alloc(alignof(T), sizeof(T))
|
||||||
|
#endif
|
||||||
);
|
);
|
||||||
freeObjects.push(ptr.get());
|
freeObjects.push(ptr.get());
|
||||||
objects.push_back(std::move(ptr));
|
objects.push_back(std::move(ptr));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user