mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Fix UB, lose type safety.
This commit is contained in:
parent
bf99bff87d
commit
3ea5600900
@ -294,23 +294,23 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
||||
while( item != end )
|
||||
{
|
||||
uint64_t ptr;
|
||||
const auto idx = MemRead( &item->hdr.idx );
|
||||
const auto idx = MemRead<uint8_t>( &item->hdr.idx );
|
||||
if( idx < (int)QueueType::Terminate )
|
||||
{
|
||||
switch( (QueueType)idx )
|
||||
{
|
||||
case QueueType::ZoneText:
|
||||
ptr = MemRead( &item->zoneText.text );
|
||||
ptr = MemRead<uint64_t>( &item->zoneText.text );
|
||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
case QueueType::Message:
|
||||
ptr = MemRead( &item->message.text );
|
||||
ptr = MemRead<uint64_t>( &item->message.text );
|
||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
case QueueType::ZoneBeginAllocSrcLoc:
|
||||
ptr = MemRead( &item->zoneBegin.srcloc );
|
||||
ptr = MemRead<uint64_t>( &item->zoneBegin.srcloc );
|
||||
SendSourceLocationPayload( ptr );
|
||||
tracy_free( (void*)ptr );
|
||||
break;
|
||||
|
@ -9,7 +9,7 @@ namespace tracy
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
tracy_force_inline T MemRead( T* ptr )
|
||||
tracy_force_inline T MemRead( void* ptr )
|
||||
{
|
||||
T val;
|
||||
memcpy( &val, ptr, sizeof( T ) );
|
||||
@ -17,7 +17,7 @@ tracy_force_inline T MemRead( T* ptr )
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
tracy_force_inline void MemWrite( T* ptr, T val )
|
||||
tracy_force_inline void MemWrite( void* ptr, T val )
|
||||
{
|
||||
memcpy( ptr, &val, sizeof( T ) );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user