1.6.22-2indexdata
[pazpar2-moved-to-github.git] / src / reclists.c
index 60df921..c4dd4e1 100644 (file)
@@ -294,7 +294,16 @@ struct reclist *reclist_create(NMEM nmem)
 void reclist_destroy(struct reclist *l)
 {
     if (l)
+    {
+        struct reclist_bucket *rb;
+        
+        for (rb = l->sorted_list; rb; rb = rb->snext)
+        {
+            wrbuf_destroy(rb->record->relevance_explain1);
+            wrbuf_destroy(rb->record->relevance_explain2);
+        }
         yaz_mutex_destroy(&l->mutex);
+    }
 }
 
 int reclist_get_num_records(struct reclist *l)
@@ -372,6 +381,8 @@ struct record_cluster *reclist_insert(struct reclist *l,
         memset(cluster->sortkeys, 0,
                sizeof(union data_types*) * service->num_sortkeys);
 
+        cluster->relevance_explain1 = wrbuf_alloc();
+        cluster->relevance_explain2 = wrbuf_alloc();
         /* attach to hash list */
         *p = new;
 
@@ -387,6 +398,16 @@ struct record_cluster *reclist_insert(struct reclist *l,
     return cluster;
 }
 
+int reclist_sortparms_cmp(struct reclist_sortparms *sort1, struct reclist_sortparms *sort2)
+{
+    int rc;
+    if (sort1 == sort2)
+        return 0;
+    if (sort1 == 0 || sort2 == 0)
+        return 1;
+    rc = strcmp(sort1->name, sort2->name) || sort1->increasing != sort2->increasing || sort1->type != sort2->type;
+    return rc;
+}
 /*
  * Local variables:
  * c-basic-offset: 4