mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 09:13:08 +00:00
Correctly zero-initialize MainThread
It can be used uninitialized in time management. Fixes all valgrind errors on './stockfish go wtime 8000 btime 8000 winc 500 binc 500' This is one (of the many) quirks of C++. There is a subtle difference between: new Foo new Foo() The first statement calls the default constructor (that in case of a POD leaves data members uninitialized), the second one performs a value-initialization (that in case of POD is equivalent to a zero-initialization) See: http://stackoverflow.com/questions/620137/do-the-parentheses-after-the-type-name-make-a-difference-with-new http://stackoverflow.com/questions/5116541/difference-between-creating-object-with-or-without No functional change.
This commit is contained in:
parent
90b052462c
commit
1c316c41bb
1 changed files with 2 additions and 2 deletions
|
@ -123,7 +123,7 @@ void Thread::idle_loop() {
|
|||
|
||||
void ThreadPool::init() {
|
||||
|
||||
push_back(new MainThread);
|
||||
push_back(new MainThread());
|
||||
read_uci_options();
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ void ThreadPool::read_uci_options() {
|
|||
assert(requested > 0);
|
||||
|
||||
while (size() < requested)
|
||||
push_back(new Thread);
|
||||
push_back(new Thread());
|
||||
|
||||
while (size() > requested)
|
||||
delete back(), pop_back();
|
||||
|
|
Loading…
Add table
Reference in a new issue