From 12a9cedc59f089e5428299641c98d74c43bb928d Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Mon, 17 Nov 2008 00:30:58 +0000 Subject: Convert while(1) loop into do while git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@67 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- numsort.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/numsort.c b/numsort.c index 36dbff6..a81e051 100644 --- a/numsort.c +++ b/numsort.c @@ -42,7 +42,7 @@ DoNumSort (void) long* array = NULL; clock_t total_time = 0; int iterations = 0; - static int num_arrays = 1; + static int num_arrays = 0; static bool is_adjusted = false; if (is_adjusted == false) { @@ -54,7 +54,9 @@ DoNumSort (void) ** enough arrays are built to handle the tolerance. */ - while (1) { + do { + ++num_arrays; + array = realloc(array, num_arrays * ARRAY_SIZE * sizeof(long)); if (!array) { fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); @@ -67,12 +69,7 @@ DoNumSort (void) ** minimum, then allocate for more arrays and ** try again. */ - if (DoNumSortIteration(array, num_arrays) > MINIMUM_TICKS) { - break; - } - - ++num_arrays; - } + } while (DoNumSortIteration(array, num_arrays) <= MINIMUM_TICKS); } else { array = malloc(num_arrays * ARRAY_SIZE * sizeof(long)); if (!array) { -- cgit v1.2.3