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:
Brian Gianforcaro 2021-05-28 05:09:00 -07:00 committed by Andreas Kling
parent 9b1ff3d3ac
commit 99e23a711d
Notes: sideshowbarker 2024-07-18 17:14:57 +09:00

View File

@ -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;