Merge pull request #197 from jwdevel/use-rpmalloc-in-ProfilerThreadDataKey

Use tracy_malloc rather than 'new' in ProfilerThreadDataKey
This commit is contained in:
Bartosz Taudul 2021-04-12 19:35:24 +02:00 committed by GitHub
commit 207a48e986
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
} }
}; };