]> git.sesse.net Git - stockfish/commitdiff
Correct zero-init of Thread data members
authorMarco Costalba <mcostalba@gmail.com>
Thu, 5 Jan 2017 07:50:17 +0000 (08:50 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 5 Jan 2017 07:50:17 +0000 (08:50 +0100)
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.

src/movepick.h
src/thread.cpp

index 6fbd8be1387fc46ce277a03f29a1f2442171ac19..999ec9660d7450474232be18ee64e6970e8bf09f 100644 (file)
@@ -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]; }
   T* operator[](Piece pc) { return table[pc]; }
   void clear() { std::memset(table, 0, sizeof(table)); }
   const T* operator[](Piece pc) const { return table[pc]; }
   T* operator[](Piece pc) { return table[pc]; }
   void clear() { std::memset(table, 0, sizeof(table)); }
index 65e170a0628b51dd4a1a3f0e20fc5c94d6628241..3c3de60d93c39badc0d1b8f631ada0b33c4f0067 100644 (file)
@@ -37,8 +37,6 @@ Thread::Thread() {
   resetCalls = exit = false;
   maxPly = callsCnt = 0;
   tbHits = 0;
   resetCalls = exit = false;
   maxPly = callsCnt = 0;
   tbHits = 0;
-  history.clear();
-  counterMoves.clear();
   idx = Threads.size(); // Start from 0
 
   std::unique_lock<Mutex> lk(mutex);
   idx = Threads.size(); // Start from 0
 
   std::unique_lock<Mutex> lk(mutex);