summaryrefslogtreecommitdiff
path: root/Kernel/KBufferBuilder.cpp
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-06-20 10:04:41 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-06-24 17:35:49 +0430
commit00915e89482994a07321fe0788e12cdab0b761fe (patch)
tree4e5a16ac77beb0f9ad89f959b00e986c168135e9 /Kernel/KBufferBuilder.cpp
parent5491e0cdcc02916d44ca1f43eab8919d28e4406c (diff)
downloadserenity-00915e89482994a07321fe0788e12cdab0b761fe.zip
AK: Add factory methods for creating smart pointers
These functions abstract away the need to call the proper new operator ("throwing" or "non-throwing") and manually adopt the resulting raw pointer. Modelled after the existing `NonnullOwnPtr<T> make()` functions, these forward their parameters to the object's constructor. Note: These can't be used in the common "factory method" idiom, as private constructors can't be called from a standalone function. The naming is consistent with AK's and Shell's previous implementation of these: - `make` creates a `NonnullOwnPtr<T>` and aborts if the allocation could not be performed. - `try_make` creates an `OwnPtr<T>`, which may be null if the allocation failed. - `create` creates a `NonnullRefPtr<T>`, and aborts on allocation failure. - `try_create` creates a `RefPtr<T>`, which may be null if the allocation was not successful.
Diffstat (limited to 'Kernel/KBufferBuilder.cpp')
0 files changed, 0 insertions, 0 deletions