Fix Pthread memset warning and add comment. (#3625)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions

This commit is contained in:
squidbus 2025-09-19 02:17:30 -07:00 committed by GitHub
parent 71e81c836c
commit be80276ec3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -100,7 +100,9 @@ Pthread* ThreadState::Alloc(Pthread* curthread) {
tcb = TcbCtor(thread, 1 /* initial tls */);
}
if (tcb != nullptr) {
memset(thread, 0, sizeof(Pthread));
// Initialize thread struct memory to 0. This is safe since it will be constructed
// immediately after.
std::memset(static_cast<void*>(thread), 0, sizeof(Pthread));
std::construct_at(thread);
thread->tcb = tcb;
thread->sleepqueue = new SleepQueue{};