mirror of
https://github.com/wolfpld/tracy.git
synced 2026-06-08 00:23:47 +00:00
Enforce same type in MemWrite.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define __TRACYALIGN_HPP__
|
||||
|
||||
#include <string.h>
|
||||
#include <type_traits>
|
||||
|
||||
#include "TracyForceInline.hpp"
|
||||
|
||||
@@ -9,17 +10,18 @@ namespace tracy
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
tracy_force_inline T MemRead( const void* ptr )
|
||||
tracy_force_inline T MemRead( const T* ptr )
|
||||
{
|
||||
T val;
|
||||
memcpy( &val, ptr, sizeof( T ) );
|
||||
return val;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
tracy_force_inline void MemWrite( void* ptr, T val )
|
||||
template<typename T, typename U>
|
||||
tracy_force_inline void MemWrite( T* ptr, U val )
|
||||
{
|
||||
memcpy( ptr, &val, sizeof( T ) );
|
||||
static_assert( std::is_same<T, U>::value, "MemWrite type mismatch" );
|
||||
memcpy( (void*)ptr, &val, sizeof( T ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user