mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-31 23:08:22 -04:00
ams: prefer construct_at/destroy_at over placement new/explicit destructor
This commit is contained in:
parent
aff0da9427
commit
d84dcb653d
49 changed files with 217 additions and 171 deletions
|
@ -30,8 +30,8 @@ namespace ams::lmem::impl {
|
|||
|
||||
void InitializeHeapHead(HeapHead *out, u32 magic, void *start, void *end, u32 option) {
|
||||
/* Call member constructors. */
|
||||
new (&out->list_node) util::IntrusiveListNode;
|
||||
new (&out->child_list) decltype(out->child_list);
|
||||
std::construct_at(std::addressof(out->list_node));
|
||||
std::construct_at(std::addressof(out->child_list));
|
||||
|
||||
/* Set fields. */
|
||||
out->magic = magic;
|
||||
|
|
|
@ -147,12 +147,11 @@ namespace ams::lmem::impl {
|
|||
}
|
||||
|
||||
inline ExpHeapMemoryBlockHead *InitializeMemoryBlock(const MemoryRegion ®ion, u16 magic) {
|
||||
ExpHeapMemoryBlockHead *block = reinterpret_cast<ExpHeapMemoryBlockHead *>(region.start);
|
||||
/* Construct the block. */
|
||||
ExpHeapMemoryBlockHead *block = std::construct_at(reinterpret_cast<ExpHeapMemoryBlockHead *>(region.start));
|
||||
|
||||
/* Ensure all member constructors are called. */
|
||||
new (block) ExpHeapMemoryBlockHead;
|
||||
|
||||
block->magic = magic;
|
||||
/* Initialize all members. */
|
||||
block->magic = magic;
|
||||
block->attributes = 0;
|
||||
block->block_size = GetPointerDifference(GetMemoryBlockStart(block), region.end);
|
||||
|
||||
|
@ -175,8 +174,8 @@ namespace ams::lmem::impl {
|
|||
InitializeHeapHead(heap_head, ExpHeapMagic, GetExpHeapMemoryStart(exp_heap_head), end, option);
|
||||
|
||||
/* Call exp heap member constructors. */
|
||||
new (&exp_heap_head->free_list) ExpHeapMemoryBlockList;
|
||||
new (&exp_heap_head->used_list) ExpHeapMemoryBlockList;
|
||||
std::construct_at(std::addressof(exp_heap_head->free_list));
|
||||
std::construct_at(std::addressof(exp_heap_head->used_list));
|
||||
|
||||
/* Set exp heap fields. */
|
||||
exp_heap_head->group_id = DefaultGroupId;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue