1.hash 初始化
struct lh_table *lh_table_new(int size, lh_entry_free_fn *free_fn, lh_hash_fn *hash_fn,
lh_equal_fn *equal_fn)
{
int i;
struct lh_table *t;
/* Allocate space for elements to avoid divisions by zero. */
assert(size > 0);
t = (struct lh_table *)calloc(1, sizeof(struct lh_table));
if (!t)
return NULL;
t->count = 0;
t->size = size;
t->table = (struct lh_entry *)calloc(size, sizeof(struct lh_entry));
if (!t->table)
{
free(t);
return NULL;
}
t->free_fn = free_fn;
t->hash_fn = hash_fn;
t->equal_fn = equal_fn;
for (i = 0; i < size; i++)
t-