ams: prefer construct_at/destroy_at over placement new/explicit destructor
This commit is contained in:
@@ -80,7 +80,7 @@ namespace ams::ddsf {
|
||||
|
||||
DeviceCodeEntry &Construct(DeviceCode dc, IDevice *dev) {
|
||||
AMS_ASSERT(!this->IsConstructed());
|
||||
DeviceCodeEntry *entry = new (GetPointer(this->entry_storage)) DeviceCodeEntry(dc, dev);
|
||||
DeviceCodeEntry *entry = util::ConstructAt(this->entry_storage, dc, dev);
|
||||
this->is_constructed = true;
|
||||
return *entry;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace ams::ddsf {
|
||||
|
||||
void Destroy() {
|
||||
AMS_ASSERT(this->IsConstructed());
|
||||
GetReference(this->entry_storage).~DeviceCodeEntry();
|
||||
util::DestroyAt(this->entry_storage);
|
||||
this->is_constructed = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,8 @@ namespace ams::sf::cmif {
|
||||
if (storage == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return new (storage) Domain(this);
|
||||
|
||||
return std::construct_at(static_cast<Domain *>(storage), this);
|
||||
}
|
||||
public:
|
||||
static void DestroyDomainServiceObject(DomainServiceObject *obj) {
|
||||
|
||||
@@ -732,12 +732,12 @@ namespace ams::sf::impl {
|
||||
template<size_t Index, typename Interface>
|
||||
SharedPointer<Interface> *GetOutObjectSharedPointer() {
|
||||
static_assert(sizeof(SharedPointer<Interface>) == sizeof(SharedPointer<sf::IServiceObject>));
|
||||
return static_cast<SharedPointer<Interface> *>(static_cast<void *>(&out_shared_pointers[Index]));
|
||||
return static_cast<SharedPointer<Interface> *>(static_cast<void *>(GetPointer(out_shared_pointers[Index])));
|
||||
}
|
||||
|
||||
template<size_t Index, typename Interface>
|
||||
Out<SharedPointer<Interface>> GetOutObject() {
|
||||
auto sp = new (GetOutObjectSharedPointer<Index, Interface>()) SharedPointer<Interface>;
|
||||
auto sp = std::construct_at(GetOutObjectSharedPointer<Index, Interface>());
|
||||
return Out<SharedPointer<Interface>>(sp, &this->out_object_ids[Index]);
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace ams::sf {
|
||||
|
||||
void DisposeImpl() {
|
||||
Allocator *a = this->GetAllocator();
|
||||
this->~Object();
|
||||
std::destroy_at(this);
|
||||
operator delete(this, a);
|
||||
}
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user