const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0]);
const float max_load_factor = 0.65;
+
+
/*****************************************************************************/
struct hashtable *
create_hashtable(unsigned int minsize,
}
/*****************************************************************************/
-int
-hashtable_insert(struct hashtable *h, void *k, void *v)
+int hashtable_insert(struct hashtable *h, void *k, void *v)
{
/* This method allows duplicate keys - but they shouldn't be used */
unsigned int tindex;
}
e = (struct entry *)malloc(sizeof(struct entry));
if (NULL == e) { --(h->entrycount); return 0; } /*oom*/
+
e->h = hash(h,k);
tindex = indexFor(h->tablelength,e->h);
e->k = k;
while (NULL != e)
{
/* Check hash value to short circuit heavier comparison */
- if ((hashvalue == e->h) && (h->eqfn(k, e->k))) return e->v;
- e = e->next;
+ if ((hashvalue == e->h) && (h->eqfn(k, e->k))) {
+ return e->v;
+ }
+ e = e->next;
}
return NULL;
}