[C++] 纯文本查看 复制代码
#define SYMBOL_HASH_SIZE 1024
static struct symbol *symbolhash[SYMBOL_HASH_SIZE];
... ...
/* This is based on the hash agorithm from gdbm, via tdb */
static inline unsigned int tdb_hash(const char *name)
{
unsigned value; /* Used to compute the hash value. */
unsigned i; /* Used to cycle through random values. */
/* Set the initial value from the key size. */
for (value = 0x238F13AF * strlen(name), i = 0; name; i++)
value = (value + (((unsigned char *)name) << (i*5 % 24)));
return (1103515243 * value + 12345);
}
symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]