Merge pull request #51656 from AndreaCatania/paged-allocator-initializer

The `PagedAllocator` can now allocate objects with non empty constructors.
This commit is contained in:
Rémi Verschelde 2021-08-14 14:12:47 +02:00 committed by GitHub
commit 087ec7b8ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -50,7 +50,8 @@ class PagedAllocator {
SpinLock spin_lock;
public:
T *alloc() {
template <class... Args>
T *alloc(const Args &&...p_args) {
if (thread_safe) {
spin_lock.lock();
}
@ -75,7 +76,7 @@ public:
if (thread_safe) {
spin_lock.unlock();
}
memnew_placement(alloc, T);
memnew_placement(alloc, T(p_args...));
return alloc;
}