X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Ftt.cpp;h=773f03ccbac463929faf254ec4cb8e591d42c224;hp=8918e515fd5180c8c5a5f21523c4f5c2e2268538;hb=141410f177c2514493f40d21a426490047cf97de;hpb=1e7aaed8bc4247a742d515811f0e484ff40309b8 diff --git a/src/tt.cpp b/src/tt.cpp index 8918e515..773f03cc 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -55,18 +55,18 @@ void TranspositionTable::set_size(size_t mbSize) { size_t newSize = 1024; - // Transposition table consists of clusters and - // each cluster consists of ClusterSize number of TTEntries. - // Each non-empty entry contains information of exactly one position. - // newSize is the number of clusters we are going to allocate. - while ((2 * newSize) * sizeof(TTCluster) <= (mbSize << 20)) + // Transposition table consists of clusters and each cluster consists + // of ClusterSize number of TTEntries. Each non-empty entry contains + // information of exactly one position and newSize is the number of + // clusters we are going to allocate. + while (2ULL * newSize * sizeof(TTCluster) <= (mbSize << 20)) newSize *= 2; if (newSize != size) { size = newSize; delete [] entries; - entries = new TTCluster[size]; + entries = new (std::nothrow) TTCluster[size]; if (!entries) { std::cerr << "Failed to allocate " << mbSize @@ -122,7 +122,7 @@ void TranspositionTable::store(const Key posKey, Value v, ValueType t, Depth d, continue; c1 = (replace->generation() == generation ? 2 : 0); - c2 = (tte->generation() == generation ? -2 : 0); + c2 = (tte->generation() == generation || tte->type() == VALUE_TYPE_EXACT ? -2 : 0); c3 = (tte->depth() < replace->depth() ? 1 : 0); if (c1 + c2 + c3 > 0)