diff options
| author | Lioncash <mathew1800@gmail.com> | 2015-12-06 14:27:15 -0500 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2015-12-06 14:51:55 -0500 |
| commit | e7b98e27ab2c133dadd4c8054d655de79d189ebc (patch) | |
| tree | b99d6e8035462d7a62dc0462ca4a2be3930b5d0e /Source/Core | |
| parent | a0ac2b867368aa6f82ee3c471fea2cf1a450b37c (diff) | |
EXI: Use std::array and std::unique_ptr for managing channels
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/HW/EXI.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Source/Core/Core/HW/EXI.cpp b/Source/Core/Core/HW/EXI.cpp index 461f90f2db..7790b77b38 100644 --- a/Source/Core/Core/HW/EXI.cpp +++ b/Source/Core/Core/HW/EXI.cpp @@ -2,6 +2,9 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include <array> +#include <memory> + #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" @@ -24,7 +27,7 @@ namespace ExpansionInterface static int changeDevice; static int updateInterrupts; -static CEXIChannel *g_Channels[MAX_EXI_CHANNELS]; +static std::array<std::unique_ptr<CEXIChannel>, MAX_EXI_CHANNELS> g_Channels; static void ChangeDeviceCallback(u64 userdata, int cyclesLate); static void UpdateInterruptsCallback(u64 userdata, int cycles_late); @@ -37,7 +40,7 @@ void Init() } for (u32 i = 0; i < MAX_EXI_CHANNELS; i++) - g_Channels[i] = new CEXIChannel(i); + g_Channels[i] = std::make_unique<CEXIChannel>(i); if (Movie::IsPlayingInput() && Movie::IsConfigSaved()) { @@ -60,10 +63,7 @@ void Init() void Shutdown() { for (auto& channel : g_Channels) - { - delete channel; - channel = nullptr; - } + channel.reset(); } void DoState(PointerWrap &p) @@ -98,7 +98,7 @@ static void ChangeDeviceCallback(u64 userdata, int cyclesLate) u8 type = (u8)(userdata >> 16); u8 num = (u8)userdata; - g_Channels[channel]->AddDevice((TEXIDevices)type, num); + g_Channels.at(channel)->AddDevice((TEXIDevices)type, num); } void ChangeDevice(const u8 channel, const TEXIDevices device_type, const u8 device_num) @@ -111,7 +111,7 @@ void ChangeDevice(const u8 channel, const TEXIDevices device_type, const u8 devi CEXIChannel* GetChannel(u32 index) { - return g_Channels[index]; + return g_Channels.at(index).get(); } IEXIDevice* FindDevice(TEXIDevices device_type, int customIndex) |
