From 99e23a711d991eea72554ee2deae04a8a3e8c090 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Fri, 28 May 2021 05:09:00 -0700 Subject: 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(.)`. --- AK/NonnullOwnPtr.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'AK') diff --git a/AK/NonnullOwnPtr.h b/AK/NonnullOwnPtr.h index 5fa314b927..6e3f3b5963 100644 --- a/AK/NonnullOwnPtr.h +++ b/AK/NonnullOwnPtr.h @@ -143,12 +143,16 @@ private: T* m_ptr = nullptr; }; +#if !defined(KERNEL) + template inline NonnullOwnPtr adopt_own(T& object) { return NonnullOwnPtr(NonnullOwnPtr::Adopt, object); } +#endif + template inline NonnullOwnPtr make(Args&&... args) @@ -180,6 +184,8 @@ struct Formatter> : Formatter { } +#if !defined(KERNEL) using AK::adopt_own; +#endif using AK::make; using AK::NonnullOwnPtr; -- cgit v1.2.3