| 579 | // Listener api |
| 580 | |
| 581 | static ProfileResult SetThreadName(void* ctx, const char* name) |
| 582 | { |
| 583 | (void)ctx; |
| 584 | PropertyInitialize(); |
| 585 | CHECK_INITIALIZED_RETVAL(PROFILE_RESULT_NOT_INITIALIZED); |
| 586 | DM_MUTEX_SCOPED_LOCK(g_Lock); |
| 587 | int32_t thread_id = GetThreadId(); |
| 588 | const char** existing = g_ProfileContext->m_ThreadNames.Get(thread_id); |
| 589 | if (existing) |
| 590 | { |
| 591 | free((void*)*existing); |
| 592 | } |
| 593 | |
| 594 | if (g_ProfileContext->m_ThreadNames.Full()) |
| 595 | { |
| 596 | uint32_t cap = g_ProfileContext->m_ThreadNames.Capacity() + 32; |
| 597 | g_ProfileContext->m_ThreadNames.SetCapacity((cap * 2) / 3, cap); |
| 598 | } |
| 599 | g_ProfileContext->m_ThreadNames.Put(thread_id, strdup(name)); |
| 600 | return PROFILE_RESULT_OK; |
| 601 | } |
| 602 | |
| 603 | static void* CreateListener() |
| 604 | { |
no test coverage detected