X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Ftt.cpp;h=6ee63138d15497851843ce114108cddba262151e;hp=46860fe900df5b9157d3cbafa5e932c688e0de83;hb=d4763424d2728fe2dfd0a6fe747666feb6a2fdbb;hpb=a910ba71eedde4f67805f05b29215cbeff4fe5f1 diff --git a/src/tt.cpp b/src/tt.cpp index 46860fe9..6ee63138 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -63,10 +63,17 @@ void TranspositionTable::resize(size_t mbSize) { Threads.main()->wait_for_search_finished(); - free(mem); + if (mem) + aligned_ttmem_free(mem); + + if (!mbSize) + { + mem = nullptr; + return; + } clusterCount = mbSize * 1024 * 1024 / sizeof(Cluster); - table = static_cast(aligned_ttmem_alloc(clusterCount * sizeof(Cluster), &mem)); + table = static_cast(aligned_ttmem_alloc(clusterCount * sizeof(Cluster), mem)); if (!mem) { std::cerr << "Failed to allocate " << mbSize