HostAllocator: Make Create64BitAllocator() return a unique_ptr

Communicates the ownership intent in the interface.

Also removes the prototype for CreateBasicAllocator, as it isn't
implemented anywhere.
This commit is contained in:
Lioncash committed 2021-06-11 19:11:46 -04:00
1 parent 1b72f73224
commit 6fc117a67c
3 files changed
+6 -6

No files matched your search

+1 -1
View File
@@ -74,7 +74,7 @@ namespace FEXCore::Allocator {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
void SetupHooks() {
Alloc64.reset(Alloc::OSAllocator::Create64BitAllocator());
Alloc64 = Alloc::OSAllocator::Create64BitAllocator();
__mmap_hook = FEX_mmap;
__munmap_hook = FEX_munmap;
FEXCore::Allocator::mmap = FEX_mmap;
+2 -2
View File
@@ -709,7 +709,7 @@ OSAllocator_64Bit::~OSAllocator_64Bit() {
}
}
Alloc::HostAllocator *Create64BitAllocator() {
return new OSAllocator_64Bit{};
std::unique_ptr<Alloc::HostAllocator> Create64BitAllocator() {
return std::make_unique<OSAllocator_64Bit>();
}
}
+3 -3
View File
@@ -1,6 +1,8 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <memory>
#include <sys/types.h>
constexpr static uint64_t PAGE_SIZE = 4096;
@@ -36,10 +38,8 @@ static inline uint64_t AlignUp(uint64_t value, uint64_t size) {
virtual void *memalign(size_t alignment, size_t size) = 0;
virtual void free(void *ptr) = 0;
};
GlobalAllocator *CreateBasicAllocator(HostAllocator *Alloc);
}
namespace Alloc::OSAllocator {
Alloc::HostAllocator *Create64BitAllocator();
std::unique_ptr<Alloc::HostAllocator> Create64BitAllocator();
}