]> code.citadel.org Git - citadel.git/blobdiff - citadel/room_ops.c
Message Deletion: only use one memmove to remove leading empty message numbers
[citadel.git] / citadel / room_ops.c
index 998cf8f1cdf232d6cfe5801edaa07a603b2e3278..010fa12766a3e617e9adbe6df7de2395e9d1bb20 100644 (file)
@@ -659,6 +659,7 @@ int sort_msglist_cmp(const void *m1, const void *m2) {
 int sort_msglist(long listptrs[], int oldcount)
 {
        int numitems;
+       int i = 0;
 
        numitems = oldcount;
        if (numitems < 2) {
@@ -669,9 +670,12 @@ int sort_msglist(long listptrs[], int oldcount)
        qsort(listptrs, numitems, sizeof(long), sort_msglist_cmp);
 
        /* and yank any nulls */
-       while ((numitems > 0) && (listptrs[0] == 0L)) {
-               memmove(&listptrs[0], &listptrs[1], (sizeof(long) * (numitems - 1)));
-               --numitems;
+       while ((i < numitems) && (listptrs[i] == 0L)) i++;
+
+       if (i > 0)
+       {
+               memmove(&listptrs[0], &listptrs[i], (sizeof(long) * (numitems - i)));
+               numitems-=i;
        }
 
        return (numitems);
@@ -1704,7 +1708,7 @@ void cmd_seta(char *new_ra)
  */
 void cmd_rinf(char *gargs)
 {
-       char filename[128];
+       char filename[PATH_MAX];
        char buf[SIZ];
        FILE *info_fp;