diff options
author | Matt Turner <mattst88@gmail.com> | 2008-11-17 00:30:58 +0000 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2008-11-17 00:30:58 +0000 |
commit | 12a9cedc59f089e5428299641c98d74c43bb928d (patch) | |
tree | bfae94b3e58720746ca4223508d9dfe4a746f97d | |
parent | c5d434d9437537f69453ff7e7ca1607da87cfd02 (diff) |
Convert while(1) loop into do while
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@67 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
-rw-r--r-- | numsort.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -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) { |