From f32b79e612575718ec770f1c6ec2ec16894de3ce Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 2 Sep 2015 15:24:33 -0400 Subject: [PATCH] GPFifo: Get rid of pointer casts --- Source/Core/Core/HW/GPFifo.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Source/Core/Core/HW/GPFifo.cpp b/Source/Core/Core/HW/GPFifo.cpp index cc09a7023d..ee09159ee0 100644 --- a/Source/Core/Core/HW/GPFifo.cpp +++ b/Source/Core/Core/HW/GPFifo.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include + #include "Common/ChunkFile.h" #include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" @@ -134,22 +136,25 @@ void FastWrite8(const u8 value) ++m_gatherPipeCount; } -void FastWrite16(const u16 value) +void FastWrite16(u16 value) { - *(u16*)(&m_gatherPipe[m_gatherPipeCount]) = Common::swap16(value); - m_gatherPipeCount += 2; + value = Common::swap16(value); + std::memcpy(&m_gatherPipe[m_gatherPipeCount], &value, sizeof(u16)); + m_gatherPipeCount += sizeof(u16); } -void FastWrite32(const u32 value) +void FastWrite32(u32 value) { - *(u32*)(&m_gatherPipe[m_gatherPipeCount]) = Common::swap32(value); - m_gatherPipeCount += 4; + value = Common::swap32(value); + std::memcpy(&m_gatherPipe[m_gatherPipeCount], &value, sizeof(u32)); + m_gatherPipeCount += sizeof(u32); } -void FastWrite64(const u64 value) +void FastWrite64(u64 value) { - *(u64*)(&m_gatherPipe[m_gatherPipeCount]) = Common::swap64(value); - m_gatherPipeCount += 8; + value = Common::swap64(value); + std::memcpy(&m_gatherPipe[m_gatherPipeCount], &value, sizeof(u64)); + m_gatherPipeCount += sizeof(u64); } } // end of namespace GPFifo