/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
 */
61 by Gustav Hartvigsson
* Made the code more easy to read.
11
hash_t
12
sdbm_hash (const char * key) {
5.2.7 by Gustav Hartvigsson
* Switched licence to a more permisive one.
13
  hash_t h=0;
14
  while(*key) h=*key++ + (h<<6) + (h<<16) - h;
15
  return h;
16
}
53 by Gustav Hartvigsson
* Finnished up s_map_add () ???
17
61 by Gustav Hartvigsson
* Made the code more easy to read.
18
hash_t
19
s_hash_object (const spointer obj) {
53 by Gustav Hartvigsson
* Finnished up s_map_add () ???
20
  /* We take the address of the pointer. */
21
  hash_t tmp_val = S_POINTER_TO_HASH_T(obj);
22
  /* Scrable it up a bit */
23
  hash_t ret_val = (tmp_val<<6);
24
  ret_val += (ret_val<<16);
25
  return ret_val;
26
}