diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-02-03 16:43:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-03 23:33:20 +0100 |
commit | a65bbbdb71d68f731b24fd816c6c140fbf5c41af (patch) | |
tree | 48a4c37ea0b661079a44d11bd7bc8348f2f764d2 /AK/RefPtr.h | |
parent | 8289727fac65688ae8df8859743516f3dee2ed9a (diff) | |
download | serenity-a65bbbdb71d68f731b24fd816c6c140fbf5c41af.zip |
Kernel: Convert try_make_ref_counted to use ErrorOr
This allows more ergonomic memory allocation failure related error
checking using the TRY macro.
Diffstat (limited to 'AK/RefPtr.h')
-rw-r--r-- | AK/RefPtr.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/AK/RefPtr.h b/AK/RefPtr.h index 5d3acff198..3696082e14 100644 --- a/AK/RefPtr.h +++ b/AK/RefPtr.h @@ -336,16 +336,16 @@ inline RefPtr<T> adopt_ref_if_nonnull(T* object) } template<typename T, class... Args> -requires(IsConstructible<T, Args...>) inline RefPtr<T> try_make_ref_counted(Args&&... args) +requires(IsConstructible<T, Args...>) inline ErrorOr<NonnullRefPtr<T>> try_make_ref_counted(Args&&... args) { - return adopt_ref_if_nonnull(new (nothrow) T(forward<Args>(args)...)); + return adopt_nonnull_ref_or_enomem(new (nothrow) T(forward<Args>(args)...)); } // FIXME: Remove once P0960R3 is available in Clang. template<typename T, class... Args> -inline RefPtr<T> try_make_ref_counted(Args&&... args) +inline ErrorOr<NonnullRefPtr<T>> try_make_ref_counted(Args&&... args) { - return adopt_ref_if_nonnull(new (nothrow) T { forward<Args>(args)... }); + return adopt_nonnull_ref_or_enomem(new (nothrow) T { forward<Args>(args)... }); } template<typename T> |