hash.c (455B)
1 /* $Id$ */ 2 #include <string.h> 3 #include "hash.h" 4 #include <gc.h> 5 6 static unsigned int 7 hashfunc(char *s) 8 { 9 unsigned int h = 0; 10 while (*s) { 11 if (h & 0x80000000) { 12 h <<= 1; 13 h |= 1; 14 } 15 else 16 h <<= 1; 17 h += *s; 18 s++; 19 } 20 return h; 21 } 22 23 #define keycomp(x,y) !strcmp(x,y) 24 25 /* *INDENT-OFF* */ 26 defhashfunc(char *, int, si) 27 defhashfunc(char *, char *, ss) 28 defhashfunc(char *, void *, sv) 29 defhashfunc_i(int, void *, iv) 30 /* *INDENT-ON* */