#include <cassert>
#include <cstring>
+#include <iostream>
#include "tt.h"
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
<< " MB for transposition table." << std::endl;
- Application::exit_with_failure();
+ exit(EXIT_FAILURE);
}
clear();
}
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)