Esempio n. 1
0
void
initFunctors(void)
{ LOCK();
  if ( !functorDefTable )
  { initAtoms();
    allocFunctorTable();
    GD->functors.highest = 1;
    registerBuiltinFunctors();
    registerControlFunctors();
    registerArithFunctors();
  }
  UNLOCK();
}
Esempio n. 2
0
static void
rehashFunctors(void)
{ FunctorDef *oldtab = functorDefTable;
  int oldbucks       = functor_buckets;
  size_t index;
  int i, last = FALSE;

  functor_buckets *= 2;
  allocFunctorTable();

  DEBUG(MSG_HASH_STAT,
	Sdprintf("Rehashing functor-table to %d entries\n", functor_buckets));

  for(index=1, i=0; !last; i++)
  { size_t upto = (size_t)2<<i;
    FunctorDef *b = GD->functors.array.blocks[i];

    if ( upto >= GD->functors.highest )
    { upto = GD->functors.highest;
      last = TRUE;
    }

    for(; index<upto; index++)
    { FunctorDef f = b[index];

      if ( f )
      { size_t v = pointerHashValue(f->name, functor_buckets);

	f->next = functorDefTable[v];
	functorDefTable[v] = f;
      }
    }
  }

  freeHeap(oldtab, oldbucks * sizeof(FunctorDef));
}