projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6b74231
)
Message Deletion: only use one memmove to remove leading empty message numbers
author
Wilfried Goesgens
<dothebart@citadel.org>
Sat, 8 Jun 2013 15:02:49 +0000
(17:02 +0200)
committer
Wilfried Goesgens
<dothebart@citadel.org>
Sat, 8 Jun 2013 15:02:49 +0000
(17:02 +0200)
citadel/room_ops.c
patch
|
blob
|
history
diff --git
a/citadel/room_ops.c
b/citadel/room_ops.c
index c657378f89af5885ca82fcf0d9dc3d68125569af..010fa12766a3e617e9adbe6df7de2395e9d1bb20 100644
(file)
--- a/
citadel/room_ops.c
+++ b/
citadel/room_ops.c
@@
-659,6
+659,7
@@
int sort_msglist_cmp(const void *m1, const void *m2) {
int sort_msglist(long listptrs[], int oldcount)
{
int numitems;
int sort_msglist(long listptrs[], int oldcount)
{
int numitems;
+ int i = 0;
numitems = oldcount;
if (numitems < 2) {
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 */
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);
}
return (numitems);