From d07d9f3110c1ee425872eb349a5ddd6a75941e39 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 10 Feb 2017 19:31:21 -0500 Subject: [PATCH] Control: Convert raw pointer parameter into unique_ptr Raw pointers shouldn't be used as boundaries in scenarios where ownership is being taken. --- Source/Core/InputCommon/ControllerEmu/Control/Control.cpp | 5 ++++- Source/Core/InputCommon/ControllerEmu/Control/Control.h | 2 +- Source/Core/InputCommon/ControllerEmu/Control/Input.cpp | 3 ++- Source/Core/InputCommon/ControllerEmu/Control/Output.cpp | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp b/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp index 00f9a71069..56c4cba12d 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp +++ b/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp @@ -3,11 +3,14 @@ // Refer to the license.txt file included. #include "InputCommon/ControllerEmu/Control/Control.h" + +#include #include "InputCommon/ControlReference/ControlReference.h" namespace ControllerEmu { -Control::Control(ControlReference* ref, const std::string& name_) : control_ref(ref), name(name_) +Control::Control(std::unique_ptr ref, const std::string& name_) + : control_ref(std::move(ref)), name(name_) { } diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Control.h b/Source/Core/InputCommon/ControllerEmu/Control/Control.h index ef88ebd328..1f7a64ed50 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Control.h +++ b/Source/Core/InputCommon/ControllerEmu/Control/Control.h @@ -20,6 +20,6 @@ public: const std::string name; protected: - Control(ControlReference* ref, const std::string& name); + Control(std::unique_ptr ref, const std::string& name); }; } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp b/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp index 0f2e400e56..8ff04e68a1 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp +++ b/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp @@ -4,12 +4,13 @@ #include "InputCommon/ControllerEmu/Control/Input.h" +#include #include #include "InputCommon/ControlReference/ControlReference.h" namespace ControllerEmu { -Input::Input(const std::string& name_) : Control(new InputReference, name_) +Input::Input(const std::string& name_) : Control(std::make_unique(), name_) { } } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp b/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp index 24d7b30499..a031893410 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp +++ b/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp @@ -4,12 +4,13 @@ #include "InputCommon/ControllerEmu/Control/Output.h" +#include #include #include "InputCommon/ControlReference/ControlReference.h" namespace ControllerEmu { -Output::Output(const std::string& name_) : Control(new OutputReference, name_) +Output::Output(const std::string& name_) : Control(std::make_unique(), name_) { } } // namespace ControllerEmu