mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 10:57:43 +00:00
Fixed a bug that the training data generator crahses on memory allocation.
This commit is contained in:
+1
-1
@@ -271,7 +271,7 @@ public:
|
|||||||
|
|
||||||
template <typename U> AlignedAllocator(const AlignedAllocator<U>&) {}
|
template <typename U> AlignedAllocator(const AlignedAllocator<U>&) {}
|
||||||
|
|
||||||
T* allocate(std::size_t n) { return (T*)std_aligned_alloc(n * sizeof(T), alignof(T)); }
|
T* allocate(std::size_t n) { return (T*)std_aligned_alloc(alignof(T), n * sizeof(T)); }
|
||||||
void deallocate(T* p, std::size_t n) { std_aligned_free(p); }
|
void deallocate(T* p, std::size_t n) { std_aligned_free(p); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ IntType Round(double value) {
|
|||||||
// make_shared with alignment
|
// make_shared with alignment
|
||||||
template <typename T, typename... ArgumentTypes>
|
template <typename T, typename... ArgumentTypes>
|
||||||
std::shared_ptr<T> MakeAlignedSharedPtr(ArgumentTypes&&... arguments) {
|
std::shared_ptr<T> MakeAlignedSharedPtr(ArgumentTypes&&... arguments) {
|
||||||
const auto ptr = new(std_aligned_alloc(sizeof(T), alignof(T)))
|
const auto ptr = new(std_aligned_alloc(alignof(T), sizeof(T)))
|
||||||
T(std::forward<ArgumentTypes>(arguments)...);
|
T(std::forward<ArgumentTypes>(arguments)...);
|
||||||
return std::shared_ptr<T>(ptr, AlignedDeleter<T>());
|
return std::shared_ptr<T>(ptr, AlignedDeleter<T>());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user