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