Fix a possible overflow in TT resize

On platforms where size_t is 32 bit, we
can have an overflow in this expression:

(mbSize * 1024 * 1024)

Fix it setting max hash size of 2GB on platforms
where size_t is 32 bit.

A small rename while there: now struct Cluster
is definied inside class TranspositionTable so
we should drop the redundant TT prefix.

No functional change.
This commit is contained in:
Marco Costalba
2015-01-17 09:04:25 +01:00
parent 58fdb84b0d
commit 595fc342cf
3 changed files with 10 additions and 8 deletions

View File

@@ -76,7 +76,7 @@ class TranspositionTable {
static const int CacheLineSize = 64;
static const int TTClusterSize = 3;
struct TTCluster {
struct Cluster {
TTEntry entry[TTClusterSize];
char padding[2]; // Align to the cache line size
};
@@ -96,7 +96,7 @@ public:
private:
size_t clusterCount;
TTCluster* table;
Cluster* table;
void* mem;
uint8_t generation8; // Size must be not bigger than TTEntry::genBound8
};