All pastes #395857 Raw Edit

Untitled

public text v1 · immutable
·published 2007-03-15 10:31 UTC
rendered paste body
// put_hashset:
//
// Takes are reference to the dictionary hashtable as well
// as a cstring "key" to be hashed and added to the 
// dictionary hashtable. Determines whether or not array
// doubling is necessary.

void put_hashset (hashset_ref hash, hashset_key_t key) {
  cstring key_nodevalue;
  hashnode_ref new;
  hashcode_t hash_number;
  hash_number = strhash (key);
  hash_number = hash_number % (hash->header_dim);
  key_nodevalue = strdup (key);
  assert (key_nodevalue);
  new = malloc (sizeof (struct hashnode));
  assert (new);
  new -> key = key_nodevalue;
  new -> link = hash->headers[hash_number];
  hash->headers[hash_number] = new;
  (hash->load_count)++;
}