diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h index 30e567aae1..582693d9e4 100644 --- a/AK/OwnPtr.h +++ b/AK/OwnPtr.h @@ -10,6 +10,8 @@ #include #ifdef KERNEL # include +#else +# include #endif #define OWNPTR_SCRUB_BYTE 0xf0 @@ -216,6 +218,15 @@ inline Kernel::KResultOr> adopt_nonnull_own_or_enomem(T* object return ENOMEM; return result.release_nonnull(); } +#else +template +inline ErrorOr> adopt_nonnull_own_or_enomem(T* object) +{ + auto result = adopt_own_if_nonnull(object); + if (!result) + return ENOMEM; + return result.release_nonnull(); +} #endif template @@ -242,10 +253,7 @@ struct Traits> : public GenericTraits> { } +using AK::adopt_nonnull_own_or_enomem; using AK::adopt_own_if_nonnull; using AK::OwnPtr; using AK::try_make; - -#ifdef KERNEL -using AK::adopt_nonnull_own_or_enomem; -#endif