mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 09:06:45 +08:00
Correct zero-init of Thread data members
If not explicitly initialized in a class constructor, then all data members are default-initialized when the corresponing struct/class is instanced. For array and built-in types (int, char, etc..) default-initialization is a no-op and we need to explicitly zero them. No functional change.
This commit is contained in:
@@ -41,6 +41,7 @@ struct Stats {
|
|||||||
|
|
||||||
static const Value Max = Value(1 << 28);
|
static const Value Max = Value(1 << 28);
|
||||||
|
|
||||||
|
Stats() { clear(); }
|
||||||
const T* operator[](Piece pc) const { return table[pc]; }
|
const T* operator[](Piece pc) const { return table[pc]; }
|
||||||
T* operator[](Piece pc) { return table[pc]; }
|
T* operator[](Piece pc) { return table[pc]; }
|
||||||
void clear() { std::memset(table, 0, sizeof(table)); }
|
void clear() { std::memset(table, 0, sizeof(table)); }
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ Thread::Thread() {
|
|||||||
resetCalls = exit = false;
|
resetCalls = exit = false;
|
||||||
maxPly = callsCnt = 0;
|
maxPly = callsCnt = 0;
|
||||||
tbHits = 0;
|
tbHits = 0;
|
||||||
history.clear();
|
|
||||||
counterMoves.clear();
|
|
||||||
idx = Threads.size(); // Start from 0
|
idx = Threads.size(); // Start from 0
|
||||||
|
|
||||||
std::unique_lock<Mutex> lk(mutex);
|
std::unique_lock<Mutex> lk(mutex);
|
||||||
|
|||||||
Reference in New Issue
Block a user