From abd3b124bea3d491bc009990dd1bec74efd012bf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 24 Aug 2015 08:58:31 -0400 Subject: [PATCH] Memmap: Remove pointer casts --- Source/Core/Core/HW/Memmap.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/HW/Memmap.cpp b/Source/Core/Core/HW/Memmap.cpp index 011205d577..b464051569 100644 --- a/Source/Core/Core/HW/Memmap.cpp +++ b/Source/Core/Core/HW/Memmap.cpp @@ -8,6 +8,8 @@ // However, if a JITed instruction (for example lwz) wants to access a bad memory area that call // may be redirected here (for example to Read_U32()). +#include + #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" #include "Common/MemArena.h" @@ -341,27 +343,30 @@ void Write_U8(u8 value, u32 address) void Write_U16(u16 value, u32 address) { - *(u16*)GetPointer(address) = Common::swap16(value); + u16 swapped_value = Common::swap16(value); + std::memcpy(GetPointer(address), &swapped_value, sizeof(u16)); } void Write_U32(u32 value, u32 address) { - *(u32*)GetPointer(address) = Common::swap32(value); + u32 swapped_value = Common::swap32(value); + std::memcpy(GetPointer(address), &swapped_value, sizeof(u32)); } void Write_U64(u64 value, u32 address) { - *(u64*)GetPointer(address) = Common::swap64(value); + u64 swapped_value = Common::swap64(value); + std::memcpy(GetPointer(address), &swapped_value, sizeof(u64)); } void Write_U32_Swap(u32 value, u32 address) { - *(u32*)GetPointer(address) = value; + std::memcpy(GetPointer(address), &value, sizeof(u32)); } void Write_U64_Swap(u64 value, u32 address) { - *(u64*)GetPointer(address) = value; + std::memcpy(GetPointer(address), &value, sizeof(u64)); } } // namespace