Include netinet/in.h for IP resolve types. Makes pazpar2 run happily
[pazpar2-moved-to-github.git] / src / termlists.c
index e586169..027d057 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: termlists.c,v 1.2 2007-01-08 12:43:41 adam Exp $
+ * $Id: termlists.c,v 1.4 2007-01-10 10:04:23 adam Exp $
  */
 
 #include <stdlib.h>
@@ -69,7 +69,7 @@ struct termlist *termlist_create(NMEM nmem, int numterms, int highscore_size)
         hashsize <<= 1;
     res = nmem_malloc(nmem, sizeof(struct termlist));
     res->hashtable = nmem_malloc(nmem, hashsize * sizeof(struct termlist_bucket*));
-    bzero(res->hashtable, hashsize * sizeof(struct termlist_bucket*));
+    memset(res->hashtable, 0, hashsize * sizeof(struct termlist_bucket*));
     res->hashtable_size = hashsize;
     res->nmem = nmem;
     res->hashmask = hashsize - 1; // Creates a bitmask
@@ -88,7 +88,7 @@ static void update_highscore(struct termlist *tl, struct termlist_score *t)
     int smallest;
     int me = -1;
 
-    if (t->frequency < tl->highscore_min)
+    if (tl->highscore_num > tl->highscore_size && t->frequency < tl->highscore_min)
         return;
 
     smallest = 0;
@@ -101,6 +101,8 @@ static void update_highscore(struct termlist *tl, struct termlist_score *t)
     }
     if (tl->highscore_num)
         tl->highscore_min = tl->highscore[smallest]->frequency;
+    if (t->frequency < tl->highscore_min)
+        tl->highscore_min = t->frequency;
     if (me >= 0)
         return;
     if (tl->highscore_num < tl->highscore_size)