summaryrefslogtreecommitdiff
path: root/wikisort.c
diff options
context:
space:
mode:
Diffstat (limited to 'wikisort.c')
-rw-r--r--wikisort.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/wikisort.c b/wikisort.c
index b2de063..4d69582 100644
--- a/wikisort.c
+++ b/wikisort.c
@@ -204,15 +204,18 @@ void wikisort(void *unsorted, size_t nmel, size_t width, cmpfun cmp)
/* merge any previous pending as and bs */
nmel_pend_b -= offset;
- if (nmel_pend_a) {
+ if (nmel_pend_a && nmel_pend_b) {
merge_blocks(base, penda, nmel_pend_a, nmel_pend_b, width, cmp);
}
+
+ nmel_pend_a = bnmel;
+ nmel_pend_b = offset;
} else {
+ nmel_pend_a = 0;
+ nmel_pend_b = 0;
offset = 0;
}
- nmel_pend_a = bnmel;
- nmel_pend_b = offset;
penda = a.base - offset * width;
a.base += bwidth;
if (--a.blocks) {