Windows NT port.
[idzebra-moved-to-github.git] / index / zsets.c
index 1e0a590..b43ea18 100644 (file)
@@ -4,7 +4,20 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zsets.c,v $
- * Revision 1.8  1995-10-10 13:59:25  adam
+ * Revision 1.12  1997-09-25 14:57:36  adam
+ * Windows NT port.
+ *
+ * Revision 1.11  1996/12/23 15:30:46  adam
+ * Work on truncation.
+ * Bug fix: result sets weren't deleted after server shut down.
+ *
+ * Revision 1.10  1995/10/30 15:08:08  adam
+ * Bug fixes.
+ *
+ * Revision 1.9  1995/10/17  18:02:14  adam
+ * New feature: databases. Implemented as prefix to words in dictionary.
+ *
+ * Revision 1.8  1995/10/10  13:59:25  adam
  * Function rset_open changed its wflag parameter to general flags.
  *
  * Revision 1.7  1995/10/06  14:38:01  adam
  */
 #include <stdio.h>
 #include <assert.h>
+#ifdef WINDOWS
+#include <io.h>
+#else
 #include <unistd.h>
+#endif
 
 #include "zserver.h"
 #include <rstemp.h>
@@ -73,8 +90,22 @@ ZServerSet *resultSetGet (ZServerInfo *zi, const char *name)
     return NULL;
 }
 
-ZServerSetSysno *resultSetSysnoGet  (ZServerInfo *zi, const char *name, 
-                                     int num, int *positions)
+void resultSetDestroy (ZServerInfo *zi)
+{
+    ZServerSet *s, *s1;
+
+    for (s = zi->sets; s; s = s1)
+    {
+        s1 = s->next;
+        rset_delete (s->rset);
+        xfree (s->name);
+        xfree (s);
+    }
+    zi->sets = NULL;
+}
+
+ZServerSetSysno *resultSetSysnoGet (ZServerInfo *zi, const char *name, 
+                                    int num, int *positions)
 {
     ZServerSet *sset;
     ZServerSetSysno *sr;
@@ -98,11 +129,11 @@ ZServerSetSysno *resultSetSysnoGet  (ZServerInfo *zi, const char *name,
         {
             psysno = key.sysno;
             position++;
+            assert (num_i < num);
             if (position == positions[num_i])
             {
                 sr[num_i].sysno = psysno;
                 rset_score (rset, rfd, &sr[num_i].score);
-                num_i++;
                 if (++num_i == num)
                     break;
             }
@@ -117,11 +148,7 @@ ZServerSetSysno *resultSetSysnoGet  (ZServerInfo *zi, const char *name,
     return sr;
 }
 
-void resultSetRecordDel (ZServerInfo *zi, ZServerRecord *records, int num)
+void resultSetSysnoDel (ZServerInfo *zi, ZServerSetSysno *records, int num)
 {
-    int i;
-
-    for (i = 0; i<num; i++)
-        xfree (records[i].buf);
     xfree (records);
 }