1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Corrects joystick memory leaks.

This commit is contained in:
Thomas Harte 2017-10-15 20:49:47 -04:00
parent 7aaf27389c
commit 18798c9886
3 changed files with 8 additions and 8 deletions

View File

@ -107,15 +107,15 @@ class ConcreteMachine:
break;
}
joysticks_.push_back(new Joystick(bus_.get(), 0, 0));
joysticks_.push_back(new Joystick(bus_.get(), 4, 1));
joysticks_.emplace_back(new Joystick(bus_.get(), 0, 0));
joysticks_.emplace_back(new Joystick(bus_.get(), 4, 1));
}
bool insert_media(const StaticAnalyser::Media &media) override {
return false;
}
std::vector<Inputs::Joystick *> &get_joysticks() override {
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
return joysticks_;
}
@ -208,7 +208,7 @@ class ConcreteMachine:
} frame_records_[4];
unsigned int frame_record_pointer_;
bool is_ntsc_;
std::vector<Inputs::Joystick *> joysticks_;
std::vector<std::unique_ptr<Inputs::Joystick>> joysticks_;
};
}

View File

@ -295,7 +295,7 @@ class ConcreteMachine:
set_region(NTSC);
// install a joystick
joysticks_.push_back(new Joystick(*user_port_via_port_handler_, *keyboard_via_port_handler_));
joysticks_.emplace_back(new Joystick(*user_port_via_port_handler_, *keyboard_via_port_handler_));
}
~ConcreteMachine() {
@ -383,7 +383,7 @@ class ConcreteMachine:
keyboard_via_port_handler_->clear_all_keys();
}
std::vector<Inputs::Joystick *> &get_joysticks() override {
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
return joysticks_;
}
@ -622,7 +622,7 @@ class ConcreteMachine:
Region region_;
Commodore::Vic20::KeyboardMapper keyboard_mapper_;
std::vector<Inputs::Joystick *> joysticks_;
std::vector<std::unique_ptr<Inputs::Joystick>> joysticks_;
std::unique_ptr<Vic6560> mos6560_;
std::shared_ptr<UserPortVIA> user_port_via_port_handler_;

View File

@ -16,7 +16,7 @@ namespace JoystickMachine {
class Machine {
public:
virtual std::vector<Inputs::Joystick *> &get_joysticks() = 0;
virtual std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() = 0;
};
}