Pat:
Here is the Hash function, courtesy of Neil Katin:
hash(s)
unsigned char *s;
int i;
int res;
unsigned char *sp;
unsigned c;
res = strlen(s);
for (i = 1, sp = s; *sp ; i++, sp++) {
c = *sp;
if ( c >= 'a' && c <= 'z' ) {
c = c – 'a' + 'A';
}
res = (( res * 13 + c) & 0x7FF);
}
return (res);
}
Note: The computed hash value is the longword offset into the directory
block, not into the hash table. Also, don't forget to use 32 bit integers as
the default.
Ariel, I _hope_ that's not that actual code they use to compute the hash
function… I hate to think of 'i' being initialized and incremented all
those times to no purpose whenever a file name is referenced.henever
Who knows? The original snippet comes from Usenet, and is attributed to
Neil Katin. If this is the actual code, or just an educational example,
is something best determined by the parties in question. 🙂