]> andersk Git - moira.git/commitdiff
_list_queries returns a client dependent list, so don't cache that data.
authorzacheiss <zacheiss>
Mon, 26 Nov 2001 18:20:28 +0000 (18:20 +0000)
committerzacheiss <zacheiss>
Mon, 26 Nov 2001 18:20:28 +0000 (18:20 +0000)
If we skip over an entry in the queries array because our client is too
old to know about it, we still need to increment our position in the array.

server/qsubs.c

index af6c80aef08ce7815bb3e462e707e7a7ed90797e..122f9eb0237732d460dab85eb561eeaf86e9242d 100644 (file)
@@ -49,28 +49,29 @@ struct query *get_query_by_name(char *name, int version)
 void list_queries(client *cl, int (*action)(int, char *[], void *),
                  void *actarg)
 {
-  static struct query **squeries = NULL;
-  static int qcount;
+  struct query **squeries = NULL;
+  int qcount;
   struct query *q, **sq;
   char qnames[80];
   char *qnp;
   int i;
 
-  if (!squeries)
+  squeries = sq = xmalloc(QueryCount * sizeof(struct query *));
+  q = Queries;
+  for (i = 0; i < QueryCount; i++)
     {
-      squeries = sq = xmalloc(QueryCount * sizeof(struct query *));
-      q = Queries;
-      for (i = 0; i < QueryCount; i++)
+      if (q->version > cl->version)
        {
-         if (q->version > cl->version)
-           continue;
-         if (i > 0 && strcmp((*sq)->name, q->name))
-           sq++;
-         *sq = q++;
+         q++;
+         continue;
        }
-      qcount = (sq - squeries) + 1;
-      qsort(squeries, qcount, sizeof(struct query *), qcmp);
+      if (i > 0 && strcmp((*sq)->name, q->name))
+       sq++;
+      *sq = q++;
     }
+  qcount = (sq - squeries) + 1;
+  qsort(squeries, qcount, sizeof(struct query *), qcmp);
+
   sq = squeries;
 
   qnp = qnames;
@@ -85,6 +86,8 @@ void list_queries(client *cl, int (*action)(int, char *[], void *),
   (*action)(1, &qnp, actarg);
   strcpy(qnames, "_list_users");
   (*action)(1, &qnp, actarg);
+
+  free(squeries);
 }
 
 void help_query(struct query *q, int (*action)(int, char *[], void *),
This page took 0.205402 seconds and 5 git commands to generate.