From 19046a084a5e298f1ed1c32d0af3cea27f34d3c5 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Mon, 17 Nov 2008 00:34:55 +0000 Subject: Convert while(1) loop into do while git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@68 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- bitfield.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bitfield.c b/bitfield.c index 064f103..c2826e5 100644 --- a/bitfield.c +++ b/bitfield.c @@ -49,7 +49,7 @@ DoBitops(void) int iterations = 0; unsigned long nbitops; static bool is_adjusted = false; - static int bitop_array_size = 30; + static int bitop_array_size = -70; /* -70 because we want to malloc 30 and we add 100 to it in the loop */ if (is_adjusted == false) { is_adjusted = true; @@ -60,7 +60,9 @@ DoBitops(void) exit(1); } - while(1) { + do { + bitop_array_size += 100; + bitoparray = malloc(bitop_array_size * 2 * sizeof(unsigned long)); if (!bitoparray) { fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); @@ -74,12 +76,7 @@ DoBitops(void) ** minimum, then de-allocate the array, reallocate a ** larger version, and try again. */ - if(DoBitfieldIteration(bitarray, bitoparray, bitop_array_size, &nbitops) > MINIMUM_TICKS) { - break; - } - - bitop_array_size += 100; - } + } while (DoBitfieldIteration(bitarray, bitoparray, bitop_array_size, &nbitops) <= MINIMUM_TICKS); } else { /* ** Don't need to do self adjustment, just allocate -- cgit v1.2.3