Example #1
0
AFFEND


static void hashtable_expand(arc *c, value hash)
{
  unsigned int hv, index, i, j, nhashbits;
  value oldtbl, newtbl, e;

  nhashbits = HASH_BITS(hash) + 1;
  newtbl = arc_mkvector(c, HASHSIZE(nhashbits));
  ((struct cell *)newtbl)->_type = T_TABLEVEC;
  for (i=0; i<HASHSIZE(nhashbits); i++)
    XVINDEX(newtbl, i) = CUNBOUND;
  oldtbl = HASH_TABLE(hash);
  /* Search for active keys and move them into the new table */
  for (i=0; i<VECLEN(oldtbl); i++) {
    e = VINDEX(oldtbl, i);
    if (EMPTYP(e))
      continue;
    /* remove the old link now that we have a copy */
    SVINDEX(oldtbl, i, CUNBOUND);
    /* insert the old key into the new table */
    hv = (unsigned int)FIX2INT(BHASHVAL(e));
    index = hv & HASHMASK(nhashbits);
    for (j=0; !EMPTYP(VINDEX(newtbl, index)); j++)
      index = (index + PROBE(j)) & HASHMASK(nhashbits);
    BTABLE(e) = newtbl;
    XVINDEX(newtbl, index) =  e;
    SBINDEX(e, index);		/* change index */
    SVINDEX(oldtbl, i, CUNBOUND);
  }
  SET_HASHBITS(hash, nhashbits);
  SET_LLIMIT(hash, (HASHSIZE(nhashbits)*MAX_LOAD_FACTOR) / 100);
  HASH_TABLE(hash) = newtbl;
}
Example #2
0
static int hash(struct signal_struct *sig, unsigned int nr)
{
	return hash_32(hash32_ptr(sig) ^ nr, HASH_BITS(posix_timers_hashtable));
}