/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
5.2.7 by Gustav Hartvigsson
* Switched licence to a more permisive one.
1
/*
2
*/
3
4
30 by Gustav Hartvigsson
* Made the code compile using CMake.
5
#include "hash.h"
5.2.7 by Gustav Hartvigsson
* Switched licence to a more permisive one.
6
7
/*
8
 * this is the SDBM hash function from:
9
 * http://en.literateprograms.org/Hash_function_comparison_%28C,_sh%29
10
 */
53 by Gustav Hartvigsson
* Finnished up s_map_add () ???
11
hash_t sdbm_hash (const char * key) {
5.2.7 by Gustav Hartvigsson
* Switched licence to a more permisive one.
12
  hash_t h=0;
13
  while(*key) h=*key++ + (h<<6) + (h<<16) - h;
14
  return h;
15
}
53 by Gustav Hartvigsson
* Finnished up s_map_add () ???
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
}