mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
Everywhere: Use nothrow new with adopt_{ref,own}_if_nonnull
This commit converts naked `new`s to `AK::try_make` and `AK::try_create` wherever possible. If the called constructor is private, this can not be done, so we instead now use the standard-defined and compiler-agnostic `new (nothrow)`.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
00915e8948
commit
f820917a76
@@ -43,11 +43,11 @@ KResultOr<NonnullRefPtr<Thread>> Thread::try_create(NonnullRefPtr<Process> proce
|
||||
return ENOMEM;
|
||||
kernel_stack_region->set_stack(true);
|
||||
|
||||
auto block_timer = adopt_ref_if_nonnull(new Timer());
|
||||
auto block_timer = AK::try_create<Timer>();
|
||||
if (!block_timer)
|
||||
return ENOMEM;
|
||||
|
||||
auto thread = adopt_ref_if_nonnull(new Thread(move(process), kernel_stack_region.release_nonnull(), block_timer.release_nonnull()));
|
||||
auto thread = adopt_ref_if_nonnull(new (nothrow) Thread(move(process), kernel_stack_region.release_nonnull(), block_timer.release_nonnull()));
|
||||
if (!thread)
|
||||
return ENOMEM;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user