From 1e3548b039bd6b760ca3fe716c98065735110f58 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Sun, 26 Oct 2014 22:51:31 -0500 Subject: Fix buffer distribution step If there are no sorted elements to distribute the buffer into, we're done. --- common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common.h') diff --git a/common.h b/common.h index 48f3d0c..4eb5d9c 100644 --- a/common.h +++ b/common.h @@ -46,7 +46,7 @@ static void rotate(char *base, size_t size, size_t shift) static void distribute_buffer(char *base, size_t bufnmel, size_t sortnmel, size_t width, cmpfun cmp) { - while (bufnmel) { + while (bufnmel && sortnmel) { char *sorted = base + bufnmel * width; size_t insertpos = binary_search(base, sorted, sortnmel, width, cmp); if (insertpos > 0) { -- cgit v1.2.3