utlbuffer,bitbuf: misalign fix

This commit is contained in:
nillerusr 2021-11-05 19:51:41 +03:00
parent 99e02e25c9
commit 2d17c2b52f
2 changed files with 5 additions and 5 deletions

View File

@ -20,7 +20,7 @@
#include "mathlib/vector.h"
#include "basetypes.h"
#include "tier0/dbg.h"
#include "strtools.h"
#if _DEBUG
#define BITBUF_INLINE inline
@ -465,12 +465,12 @@ BITBUF_INLINE void bf_write::WriteUBitVar( unsigned int data )
// write raw IEEE float bits in little endian form
BITBUF_INLINE void bf_write::WriteBitFloat(float val)
{
long intVal;
int32 intVal;
Assert(sizeof(long) == sizeof(float));
Assert(sizeof(float) == 4);
intVal = *((long*)&val);
Q_memcpy( &intVal, &val, sizeof(intVal));
WriteUBitLong( intVal, 32 );
}

View File

@ -598,7 +598,7 @@ inline void CUtlBuffer::GetObject( T *dest )
{
if ( !m_Byteswap.IsSwappingBytes() || ( sizeof( T ) == 1 ) )
{
*dest = *(T *)PeekGet();
Q_memcpy( dest, PeekGet(), sizeof( T ) );
}
else
{
@ -661,7 +661,7 @@ inline void CUtlBuffer::GetTypeBin< float >( float &dest )
else
{
// aligned read
Q_memcmp( &dest, pData, sizeof(float) );
Q_memcmp( &dest, (void*)pData, sizeof(float) );
}
if ( m_Byteswap.IsSwappingBytes() )
{