From e7b98e27ab2c133dadd4c8054d655de79d189ebc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 6 Dec 2015 14:27:15 -0500 Subject: [PATCH] EXI: Use std::array and std::unique_ptr for managing channels --- Source/Core/Core/HW/EXI.cpp | 16 ++++++++-------- 1 file 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 +#include + #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, 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(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)