Fix Pthread memset warning and add comment. (#3625)

This commit is contained in:
squidbus
2025-09-19 02:17:30 -07:00
committed by GitHub
parent 71e81c836c
commit be80276ec3

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{};