]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/tossim/hashtable.c
For some reason nx_bool was failing on TOSSIM.
[tinyos-2.x.git] / tos / lib / tossim / hashtable.c
index f145201112b1750b6068d912ea657322c0423910..dfd450b7228fd4b8115bbbc900bffdc0240cf902 100644 (file)
@@ -24,6 +24,8 @@ static const unsigned int primes[] = {
 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,
@@ -133,8 +135,7 @@ hashtable_count(struct hashtable *h)
 }
 
 /*****************************************************************************/
-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;
@@ -149,6 +150,7 @@ hashtable_insert(struct hashtable *h, void *k, void *v)
     }
     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;
@@ -170,8 +172,10 @@ hashtable_search(struct hashtable *h, void *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;
 }