mirror of
https://github.com/wolfpld/tracy
synced 2025-04-28 20:23:51 +00:00
Use tracy_malloc rather than 'new' in ProfilerThreadDataKey
This codepath, involving a workaround for GCC < 8.4, called 'new' and 'delete' directly, which could cause infinite recursion when user-provided versions of those functions were themselves using Tracy functionality. Now, this codepath uses Tracy's internal allocator. See issues #194, #196
This commit is contained in:
parent
40efbe8529
commit
915693ac39
@ -1069,7 +1069,9 @@ public:
|
|||||||
void* p = pthread_getspecific(m_key);
|
void* p = pthread_getspecific(m_key);
|
||||||
if (!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
p = new ProfilerThreadData(GetProfilerData());
|
RPMallocInit init;
|
||||||
|
p = (ProfilerThreadData*)tracy_malloc( sizeof( ProfilerThreadData ) );
|
||||||
|
new (p) ProfilerThreadData(GetProfilerData());
|
||||||
pthread_setspecific(m_key, p);
|
pthread_setspecific(m_key, p);
|
||||||
}
|
}
|
||||||
return *static_cast<ProfilerThreadData*>(p);
|
return *static_cast<ProfilerThreadData*>(p);
|
||||||
@ -1079,7 +1081,8 @@ private:
|
|||||||
|
|
||||||
static void sDestructor(void* p)
|
static void sDestructor(void* p)
|
||||||
{
|
{
|
||||||
delete static_cast<ProfilerThreadData*>(p);
|
((ProfilerThreadData*)p)->~ProfilerThreadData();
|
||||||
|
tracy_free(p);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user