]> code.citadel.org Git - citadel.git/blobdiff - citadel/room_ops.c
* sort_msglist() now uses qsort() instead of a bubble sort
[citadel.git] / citadel / room_ops.c
index e3720e3cc948490be0f52adf888886c71c0a2805..e1d501a1c4cf7860a4544126136d64de52111303 100644 (file)
@@ -181,7 +181,7 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
        if ( (userbuf->axlevel >= 6)
           || (userbuf->usernum == roombuf->QRroomaide)
           ) {
-               retval = retval | UA_ADMINALLOWED | UA_DELETEALLOWED;
+               retval = retval | UA_ADMINALLOWED | UA_DELETEALLOWED | UA_POSTALLOWED;
        }
 
 NEWMSG:        /* By the way, we also check for the presence of new messages */
@@ -493,6 +493,15 @@ void delete_msglist(struct ctdlroom *whichroom)
 
 
 
+/*
+ * Message pointer compare function for sort_msglist()
+ */
+int sort_msglist_cmp(long *m1, long *m2) {
+       if (*m1 > *m2) return(1);
+       if (*m1 < *m2) return(-1);
+       return(0);
+}
+
 
 /*
  * sort message pointers
@@ -500,25 +509,15 @@ void delete_msglist(struct ctdlroom *whichroom)
  */
 int sort_msglist(long listptrs[], int oldcount)
 {
-       int a, b;
-       long hold1, hold2;
        int numitems;
 
        numitems = oldcount;
-       if (numitems < 2)
+       if (numitems < 2) {
                return (oldcount);
+       }
 
        /* do the sort */
-       for (a = numitems - 2; a >= 0; --a) {
-               for (b = 0; b <= a; ++b) {
-                       if (listptrs[b] > (listptrs[b + 1])) {
-                               hold1 = listptrs[b];
-                               hold2 = listptrs[b + 1];
-                               listptrs[b] = hold2;
-                               listptrs[b + 1] = hold1;
-                       }
-               }
-       }
+       qsort(listptrs, numitems, sizeof(long), sort_msglist_cmp);
 
        /* and yank any nulls */
        while ((numitems > 0) && (listptrs[0] == 0L)) {