diff options
-rw-r--r-- | wikisort.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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) { |