From d6c68e77c1f007e02b8a1c03bbf0da59251d3775 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 8 Jun 2013 17:02:49 +0200 Subject: [PATCH] Message Deletion: only use one memmove to remove leading empty message numbers --- citadel/room_ops.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/citadel/room_ops.c b/citadel/room_ops.c index c657378f8..010fa1276 100644 --- 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 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); -- 2.30.2