Don't allocate MAX_THREADS hash tables if not necessary

This prevent crashing on mobile devices with limited RAM,
currently with MAX_THREADS = 32 we would need 44MB that
could be too much for a poor cellphone.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2011-04-24 18:46:26 +01:00
parent fecefbb99c
commit 339e1b49f6
5 changed files with 40 additions and 19 deletions

View File

@@ -148,11 +148,14 @@ struct SimpleHash {
void init() {
if (entries)
return;
entries = new (std::nothrow) Entry[HashSize];
if (!entries)
{
std::cerr << "Failed to allocate " << HashSize * sizeof(Entry)
<< " bytes for material hash table." << std::endl;
<< " bytes for hash table." << std::endl;
exit(EXIT_FAILURE);
}
memset(entries, 0, HashSize * sizeof(Entry));