mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 13:43:45 +03:00
AK+Kernel: Hide AK::adopt_own from usage in the Kernel
We want to discourage folks from using APIs which lull you into a sense of false safety in terms of OOM. There are cases where you want to force allocations to succeed or crash, but those should use a more explicit API than `AK::adopt_own(.)`.
This commit is contained in:
parent
9b1ff3d3ac
commit
99e23a711d
Notes:
sideshowbarker
2024-07-18 17:14:57 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/99e23a711d9 Pull-request: https://github.com/SerenityOS/serenity/pull/7520 Reviewed-by: https://github.com/supercomputer7
@ -143,12 +143,16 @@ private:
|
||||
T* m_ptr = nullptr;
|
||||
};
|
||||
|
||||
#if !defined(KERNEL)
|
||||
|
||||
template<typename T>
|
||||
inline NonnullOwnPtr<T> adopt_own(T& object)
|
||||
{
|
||||
return NonnullOwnPtr<T>(NonnullOwnPtr<T>::Adopt, object);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class T, class... Args>
|
||||
inline NonnullOwnPtr<T>
|
||||
make(Args&&... args)
|
||||
@ -180,6 +184,8 @@ struct Formatter<NonnullOwnPtr<T>> : Formatter<const T*> {
|
||||
|
||||
}
|
||||
|
||||
#if !defined(KERNEL)
|
||||
using AK::adopt_own;
|
||||
#endif
|
||||
using AK::make;
|
||||
using AK::NonnullOwnPtr;
|
||||
|
Loading…
Reference in New Issue
Block a user