From 51fb0a6f9647ba199da10fe4f018ee36e44e65ba Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 27 Feb 2021 11:56:04 -0800 Subject: core: Switch to unique_ptr for usage of Common::Fiber. - With using unique_ptr instead of shared_ptr, we have more explicit ownership of the context. - Fixes a memory leak due to circular reference of the shared pointer. --- src/core/hle/kernel/k_thread.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/core/hle/kernel/k_thread.h') diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index c8ac656a4..a2893d939 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h @@ -293,7 +293,13 @@ public: return thread_context_64; } - [[nodiscard]] std::shared_ptr& GetHostContext(); + [[nodiscard]] Common::Fiber* GetHostContext() { + return host_context.get(); + } + + [[nodiscard]] const Common::Fiber* GetHostContext() const { + return host_context.get(); + } [[nodiscard]] ThreadState GetState() const { return thread_state & ThreadState::Mask; @@ -719,7 +725,7 @@ private: Common::SpinLock context_guard{}; // For emulation - std::shared_ptr host_context{}; + std::unique_ptr host_context{}; // For debugging std::vector wait_objects_for_debugging; -- cgit v1.2.3