Skip to content

Commit

Permalink
Reserve a fixed length for ThreadNames entries so that replacement na…
Browse files Browse the repository at this point in the history
…mes can be copied into them concurrently without freeing any memory
  • Loading branch information
Kaldaien committed Nov 29, 2024
1 parent 892b6b1 commit 62951ca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/diagnostics/debug_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2915,10 +2915,10 @@ SK_Exception_HandleThreadName (
_TRUNCATE );
}

if (ThreadNames.count (dwTid) == 0)
ThreadNames.insert ( // Do not move the string, copy it!
std::make_pair (dwTid, wide_name.c_str ())
);
// Do not move the string, resize the existing name, clear it, and append a copy!
ThreadNames [dwTid].resize (MAX_THREAD_NAME_LEN+1);
ThreadNames [dwTid].assign (wide_name.c_str ());
// * Ideally this would be a wchar_t array of fixed size

#ifdef _M_AMD64
if (SK_GetCurrentGameID () == SK_GAME_ID::EldenRing)
Expand Down

0 comments on commit 62951ca

Please sign in to comment.