summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-11-17 00:34:55 +0000
committerMatt Turner <mattst88@gmail.com>2008-11-17 00:34:55 +0000
commit19046a084a5e298f1ed1c32d0af3cea27f34d3c5 (patch)
tree21aa67f7f78bedc755dd79d22e331971680bd1ac
parent12a9cedc59f089e5428299641c98d74c43bb928d (diff)
Convert while(1) loop into do while
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@68 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
-rw-r--r--bitfield.c13
1 files 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