mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-02 22:24:26 +00: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
|
@ -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 a new issue