1 Commits
Author SHA1 Message Date
ShiftyX1 7fc1c37258 upd gitignore
x86-64 AppImage / build-appimage (ubuntu-22.04) (push) Failing after 1m23s
Build / Build (push) Failing after 17s
MSVC Build / build-windows (windows-latest) (push) Has been cancelled
Macos Build / build-dmg (push) Has been cancelled
Windows Build (CLang) / build-windows (clang, windows-latest) (push) Has been cancelled
2025-12-08 19:04:50 +03:00
+4 -15
View File
@@ -4,12 +4,9 @@
#include <mutex>
#include <vector>
#include <queue>
#include <new>
#if defined(_WIN32)
#include <malloc.h>
#else
#include <cstdlib>
#endif
namespace util {
@@ -53,21 +50,13 @@ namespace util {
std::mutex mutex;
void allocateNew() {
// Use posix_memalign on POSIX systems as aligned_alloc has stricter requirements
constexpr size_t alignment = alignof(T) < sizeof(void*) ? sizeof(void*) : alignof(T);
constexpr size_t size = sizeof(T);
void* rawPtr = nullptr;
std::unique_ptr<void, AlignedDeleter> ptr(
#if defined(_WIN32)
rawPtr = _aligned_malloc(size, alignment);
_aligned_malloc(sizeof(T), alignof(T))
#else
if (posix_memalign(&rawPtr, alignment, size) != 0) {
rawPtr = nullptr;
}
std::aligned_alloc(alignof(T), sizeof(T))
#endif
if (rawPtr == nullptr) {
throw std::bad_alloc();
}
std::unique_ptr<void, AlignedDeleter> ptr(rawPtr);
);
freeObjects.push(ptr.get());
objects.push_back(std::move(ptr));
}