Beispiel #1
0
bool BotConfig::addValue( BotConfigValue& val )
{
	int idx = findFreeIndex();
	if( idx == -1 )
	{
		MessageBox( NULL, TEXT("Cannot add var to config: overflow?"), TEXT("BotConfig"), MB_ICONWARNING );
		return false;
	}
	value[idx] = val;
	return true;
}
static SUP_THREAD* findFreeSlot(void)
{
  int32_t index;
  pthread_data_t *tab, *prev;

  prev = threadTab;
  tab  = threadTab;

  while( tab != NULL )
  {
    index = findFreeIndex( tab->free );
    if( index >= 0 )
    {
      tab->free = bitset( tab->free, index );
      return &tab->thread[index];
    }

    prev = tab;
    tab = tab->next;
  }

  // If we are here it means we lack free memory

  if(prev)
  {
	  prev->next = (pthread_data_t*)calloc( 1, sizeof(pthread_data_t) );
	  tab = prev->next;
  }
  else
  {
	  tab = (pthread_data_t*)calloc( 1, sizeof(pthread_data_t) );
	  threadTab=tab;
  }


  tab->free = bitset( tab->free, 0 );
  return &tab->thread[0];
}