void init_egtb(void) { #ifdef USE_EGTB void *buffer; buffer = malloc(EGTBCacheSize); if (buffer == NULL && (EGTBCacheSize != 0)) { printf("Could not allocate EGTB buffer.\n"); exit(EXIT_FAILURE); }; EGTBPieces = IInitializeTb (EGTBDir); printf("%d piece endgame tablebases found\n", EGTBPieces); printf("Allocated %dKb for indices and tables.\n",((cbEGTBCompBytes+1023)/1024)); if(FTbSetCacheSize (buffer, EGTBCacheSize) == FALSE && (EGTBCacheSize != 0)) { printf("Could not enable EGTB buffer.\n"); exit(EXIT_FAILURE); }; return; #else return; #endif }
tablebase_t::tablebase_t(const std::string& path, const std::size_t size) : _mutex(), _cache(new char[size]), _pieces(IInitializeTb(const_cast<char*>(path.data()))) { if (!FTbSetCacheSize(_cache.get(), size)) std::__throw_runtime_error("FTbSetCacheSize failed."); }
void CTablebases::setCacheSize(int32 cachesize) { if (m_cache_size != cachesize) { delete m_cache_ptr; m_cache_ptr = 0; m_cache_size = cachesize; if (m_cache_size) { m_cache_ptr = operator new(m_cache_size * 1024 * 1024); FTbSetCacheSize(m_cache_ptr, m_cache_size * 1024 * 1024); } } }
// scid_TB_init: // Initialises the tablebases given a directory string. All the tables // to be used must be in the directory; subdirectories are not // scanned. However, the directory string may have more than one // dircetory in it, separated by commas (,) or semicolons (;). // Returns the same value as scid_TB_MaxPieces(). uint scid_TB_Init (const char * egtb_path) { EGTB_maxpieces = (uint) IInitializeTb ((char *) egtb_path); #ifdef WINCE if (EGTB_cache != NULL) { my_Tcl_Free( (char *) EGTB_cache); } EGTB_cache = (byte *)my_Tcl_Alloc(sizeof(byte [EGTB_cachesize])); #else if (EGTB_cache != NULL) { delete[] (byte *) EGTB_cache; } EGTB_cache = new byte [EGTB_cachesize]; #endif FTbSetCacheSize (EGTB_cache, EGTB_cachesize); return EGTB_maxpieces; }