mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +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
1 changed files with 6 additions and 0 deletions
|
@ -143,12 +143,16 @@ private:
|
||||||
T* m_ptr = nullptr;
|
T* m_ptr = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined(KERNEL)
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline NonnullOwnPtr<T> adopt_own(T& object)
|
inline NonnullOwnPtr<T> adopt_own(T& object)
|
||||||
{
|
{
|
||||||
return NonnullOwnPtr<T>(NonnullOwnPtr<T>::Adopt, object);
|
return NonnullOwnPtr<T>(NonnullOwnPtr<T>::Adopt, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
inline NonnullOwnPtr<T>
|
inline NonnullOwnPtr<T>
|
||||||
make(Args&&... args)
|
make(Args&&... args)
|
||||||
|
@ -180,6 +184,8 @@ struct Formatter<NonnullOwnPtr<T>> : Formatter<const T*> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(KERNEL)
|
||||||
using AK::adopt_own;
|
using AK::adopt_own;
|
||||||
|
#endif
|
||||||
using AK::make;
|
using AK::make;
|
||||||
using AK::NonnullOwnPtr;
|
using AK::NonnullOwnPtr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue