summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/module.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/Syscalls/module.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/Syscalls/module.cpp')
-rw-r--r--Kernel/Syscalls/module.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/Syscalls/module.cpp b/Kernel/Syscalls/module.cpp
index 1ab7dd2ef0..9d267bd4ad 100644
--- a/Kernel/Syscalls/module.cpp
+++ b/Kernel/Syscalls/module.cpp
@@ -37,7 +37,7 @@ KResultOr<int> Process::sys$module_load(Userspace<const char*> user_path, size_t
auto storage = KBuffer::create_with_size(payload.size());
memcpy(storage.data(), payload.data(), payload.size());
- auto elf_image = adopt_own_if_nonnull(new ELF::Image(storage.data(), storage.size()));
+ auto elf_image = try_make<ELF::Image>(storage.data(), storage.size());
if (!elf_image)
return ENOMEM;
if (!elf_image->parse())
@@ -45,7 +45,7 @@ KResultOr<int> Process::sys$module_load(Userspace<const char*> user_path, size_t
HashMap<String, u8*> section_storage_by_name;
- auto module = adopt_own_if_nonnull(new Module());
+ auto module = try_make<Module>();
if (!module)
return ENOMEM;