mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
Kernel: Fix adopt_ref_if_nonnull(new T).release_nonnull()
pattern
This does the exact thing as `adopt_ref`, which is a recent addition to AK. Note that pointers returned by a bare new (without `nothrow`) are guaranteed not to return null, so they can safely be converted into references.
This commit is contained in:
parent
9b1157924b
commit
2a5d9a6944
Notes:
sideshowbarker
2024-07-18 11:19:15 +09:00
Author: https://github.com/BertalanD
Commit: 2a5d9a6944
Pull-request: https://github.com/SerenityOS/serenity/pull/8295
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/alimpfard
4 changed files with 4 additions and 5 deletions
|
@ -17,7 +17,7 @@ namespace Kernel {
|
|||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<MemoryDevice> MemoryDevice::must_create()
|
||||
{
|
||||
return adopt_ref_if_nonnull(new MemoryDevice).release_nonnull();
|
||||
return adopt_ref(*new MemoryDevice);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT MemoryDevice::MemoryDevice()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue