From 130f57df91e49cbf03dde638adc1b898fb772431 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 22 Aug 2014 01:02:04 -0400 Subject: [PATCH] Core: Simplify Memory::GetString --- Source/Core/Core/HW/Memmap.cpp | 17 ++++++++--------- Source/Core/Core/HW/Memmap.h | 2 +- Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp | 3 +-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Source/Core/Core/HW/Memmap.cpp b/Source/Core/Core/HW/Memmap.cpp index 707dac1fb1..c3d3099851 100644 --- a/Source/Core/Core/HW/Memmap.cpp +++ b/Source/Core/Core/HW/Memmap.cpp @@ -279,19 +279,18 @@ void ReadBigEData(u8 *data, const u32 em_address, const u32 size) memcpy(data, src, size); } -void GetString(std::string& _string, const u32 em_address) +std::string GetString(u32 em_address) { - char stringBuffer[2048]; - char *string = stringBuffer; + std::string str; char c; - u32 addr = em_address; - while ((c = Read_U8(addr))) + + while ((c = Read_U8(em_address)) != '\0') { - *string++ = c; - addr++; + str += c; + em_address++; } - *string++ = '\0'; - _string = stringBuffer; + + return str; } // GetPointer must always return an address in the bottom 32 bits of address space, so that 64-bit diff --git a/Source/Core/Core/HW/Memmap.h b/Source/Core/Core/HW/Memmap.h index 698d3b4160..d1ae34711d 100644 --- a/Source/Core/Core/HW/Memmap.h +++ b/Source/Core/Core/HW/Memmap.h @@ -118,7 +118,7 @@ void Write_U64_Swap(const u64 _Data, const u32 _Address); // Useful helper functions, used by ARM JIT void Write_F64(const double _Data, const u32 _Address); -void GetString(std::string& _string, const u32 _Address); +std::string GetString(u32 em_address); void WriteBigEData(const u8 *_pData, const u32 _Address, const size_t size); void ReadBigEData(u8 *_pDest, const u32 _Address, const u32 size); diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp index 58c8717175..56fc877e29 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp @@ -369,8 +369,7 @@ void ExecuteCommand(u32 _Address) u32 Mode = Memory::Read_U32(_Address + 0x10); DeviceID = getFreeDeviceId(); - std::string DeviceName; - Memory::GetString(DeviceName, Memory::Read_U32(_Address + 0xC)); + std::string DeviceName = Memory::GetString(Memory::Read_U32(_Address + 0xC)); WARN_LOG(WII_IPC_HLE, "Trying to open %s as %d", DeviceName.c_str(), DeviceID); if (DeviceID >= 0)