1
0
mirror of https://github.com/wolfpld/tracy synced 2025-01-15 20:08:00 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Bartosz Taudul
207a48e986
Merge pull request #197 from jwdevel/use-rpmalloc-in-ProfilerThreadDataKey
Use tracy_malloc rather than 'new' in ProfilerThreadDataKey
2021-04-12 19:35:24 +02:00
JW
915693ac39 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
2021-04-12 10:06:35 -07:00

View File

@ -1069,7 +1069,9 @@ public:
void* p = pthread_getspecific(m_key);
if (!p)
{
p = new ProfilerThreadData(GetProfilerData());
RPMallocInit init;
p = (ProfilerThreadData*)tracy_malloc( sizeof( ProfilerThreadData ) );
new (p) ProfilerThreadData(GetProfilerData());
pthread_setspecific(m_key, p);
}
return *static_cast<ProfilerThreadData*>(p);
@ -1079,7 +1081,8 @@ private:
static void sDestructor(void* p)
{
delete static_cast<ProfilerThreadData*>(p);
((ProfilerThreadData*)p)->~ProfilerThreadData();
tracy_free(p);
}
};