Browse Source

utlbuffer,bitbuf: misalign fix

pull/26/head
nillerusr 3 years ago
parent
commit
2d17c2b52f
  1. 6
      public/tier1/bitbuf.h
  2. 4
      public/tier1/utlbuffer.h

6
public/tier1/bitbuf.h

@ -20,7 +20,7 @@ @@ -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 ) @@ -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 );
}

4
public/tier1/utlbuffer.h

@ -598,7 +598,7 @@ inline void CUtlBuffer::GetObject( T *dest ) @@ -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 ) @@ -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() )
{

Loading…
Cancel
Save