From 4fb3a8b78d7711519629b19f5da664ea605a636b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 27 Aug 2015 13:43:04 -0400 Subject: [PATCH] DataReader: Get rid of pointer casts --- Source/Core/VideoCommon/DataReader.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoCommon/DataReader.h b/Source/Core/VideoCommon/DataReader.h index 0737a9bf1d..bb4914db8c 100644 --- a/Source/Core/VideoCommon/DataReader.h +++ b/Source/Core/VideoCommon/DataReader.h @@ -4,7 +4,9 @@ #pragma once -#include "Common/Common.h" +#include +#include "Common/CommonFuncs.h" +#include "Common/CommonTypes.h" class DataReader { @@ -33,9 +35,12 @@ public: template __forceinline T Peek(int offset = 0) { - T data = *(T*)(buffer + offset); + T data; + std::memcpy(&data, &buffer[offset], sizeof(T)); + if (swapped) data = Common::FromBigEndian(data); + return data; } @@ -50,7 +55,8 @@ public: { if (swapped) data = Common::FromBigEndian(data); - *(T*)(buffer) = data; + + std::memcpy(buffer, &data, sizeof(T)); buffer += sizeof(T); }