/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to src/hash.c

  • Committer: Gustav Hartvigsson
  • Date: 2015-06-18 19:01:54 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150618190154-nd5ucxkx4b1ww5xh
* Finnished up s_map_add () ???

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 * this is the SDBM hash function from:
9
9
 * http://en.literateprograms.org/Hash_function_comparison_%28C,_sh%29
10
10
 */
11
 
hash_t sdbm_hash (const unsigned char *key) {
 
11
hash_t sdbm_hash (const char * key) {
12
12
  hash_t h=0;
13
13
  while(*key) h=*key++ + (h<<6) + (h<<16) - h;
14
14
  return h;
15
15
}
 
16
 
 
17
hash_t s_hash_object (const spointer obj) {
 
18
  /* We take the address of the pointer. */
 
19
  hash_t tmp_val = S_POINTER_TO_HASH_T(obj);
 
20
  /* Scrable it up a bit */
 
21
  hash_t ret_val = (tmp_val<<6);
 
22
  ret_val += (ret_val<<16);
 
23
  return ret_val;
 
24
}