mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Properly set to zero stuff returned by 'new'
Language guarantees that c'tor is called, but without any c'tor it happens to work by accident because OS zeroes out the freshly allocated pages. The problem is that if I deallocate and allocate again, the second time pages are no more newly come by the OS and so could contain stale info. A practical case could be if we change TT size or numbers of threads on the fly while already running. Bug spotted by Justin Blanchard. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
f00c976bb2
commit
9ca4359f36
3 changed files with 3 additions and 0 deletions
|
@ -146,6 +146,7 @@ MaterialInfoTable::MaterialInfoTable() {
|
|||
<< " bytes for material hash table." << endl;
|
||||
Application::exit_with_failure();
|
||||
}
|
||||
memset(entries, 0, MaterialTableSize * sizeof(MaterialInfo));
|
||||
}
|
||||
|
||||
MaterialInfoTable::~MaterialInfoTable() {
|
||||
|
|
|
@ -90,6 +90,7 @@ PawnInfoTable::PawnInfoTable() {
|
|||
<< " bytes for pawn hash table." << std::endl;
|
||||
Application::exit_with_failure();
|
||||
}
|
||||
memset(entries, 0, PawnTableSize * sizeof(PawnInfo));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ void TranspositionTable::set_size(size_t mbSize) {
|
|||
<< " MB for transposition table." << std::endl;
|
||||
Application::exit_with_failure();
|
||||
}
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue