summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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