diff --git a/src/misc.h b/src/misc.h index fe5990e0..9ea57fa8 100644 --- a/src/misc.h +++ b/src/misc.h @@ -271,7 +271,7 @@ public: template AlignedAllocator(const AlignedAllocator&) {} - 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); } }; diff --git a/src/nnue/trainer/trainer.h b/src/nnue/trainer/trainer.h index b42cb4fa..4b467041 100644 --- a/src/nnue/trainer/trainer.h +++ b/src/nnue/trainer/trainer.h @@ -111,7 +111,7 @@ IntType Round(double value) { // make_shared with alignment template std::shared_ptr 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(arguments)...); return std::shared_ptr(ptr, AlignedDeleter()); }