summaryrefslogtreecommitdiff
path: root/Kernel/Thread.cpp
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-06-20 10:21:16 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-06-24 17:35:49 +0430
commitf820917a765d1ac74af5f66567becb955996b0d8 (patch)
tree98dc6d46387daef9ecedd815bd822753a2f8813a /Kernel/Thread.cpp
parent00915e89482994a07321fe0788e12cdab0b761fe (diff)
downloadserenity-f820917a765d1ac74af5f66567becb955996b0d8.zip
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)`.
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r--Kernel/Thread.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 90f047c45f..b2cc469246 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -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;