typedef struct _Bucket { char *key; void *value; struct _Bucket *next; } Bucket; typedef struct _HashTable { int size; Bucket* buckets; } HashTable; static int hash_str(char *key) { int hash = 0; char *cur = key; while(*(cur++) != '\0') { hash += *cur; } return hash; } // 使用这个宏来求得key在哈希表中的索引 #define HASH_INDEX(ht, key) (hash_str((key)) % (ht)->size)