diff options
-rw-r--r-- | assignment.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/assignment.c b/assignment.c index 6d653ca..cf0edf7 100644 --- a/assignment.c +++ b/assignment.c @@ -74,7 +74,7 @@ DoAssign(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) { @@ -85,7 +85,9 @@ DoAssign(void) ** are built. This process continues until ** enough arrays are built to handle the tolerance. */ - while (1) { + do { + ++num_arrays; + array = realloc(array, sizeof(long) * ASSIGNROWS * ASSIGNCOLS * num_arrays); if (!array) { fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); @@ -98,12 +100,7 @@ DoAssign(void) ** minimum, then allocate for more arrays and ** try again. */ - if (DoAssignIteration(array, num_arrays) > MINIMUM_TICKS) { - break; - } - - ++num_arrays; - } + } while (DoAssignIteration(array, num_arrays) <= MINIMUM_TICKS); } else { array = malloc(sizeof(long) * ASSIGNROWS * ASSIGNCOLS * num_arrays); if (!array) { |