diff options
author | Matt Turner <mattst88@gmail.com> | 2008-11-17 04:38:00 +0000 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2008-11-17 04:38:00 +0000 |
commit | e552489427e4d950c182a3a0221896ae65529a85 (patch) | |
tree | 76692d31f27b59f09e5d917198b32d6d667970f4 | |
parent | 55078bbd4486cfec9d884fe4c9f79b258035b0b0 (diff) |
Convert for-if-break construct to do while
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@75 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
-rw-r--r-- | linear.c | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -74,7 +74,6 @@ DoLU(void) double* bbase = NULL; LUdblptr ptra; int n; - int i; static int num_arrays = 0; static bool is_adjusted = false; @@ -109,9 +108,10 @@ DoLU(void) if (is_adjusted == false) { is_adjusted = true; - for(i=1;i<=ARRAY_MAX;i++) - { - abase = realloc(abase, sizeof(double) * LUARRAYCOLS*LUARRAYROWS*(i+1)); + do { + ++num_arrays; + + abase = realloc(abase, sizeof(double) * LUARRAYCOLS * LUARRAYROWS * (num_arrays + 1)); if (!abase) { fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); free(a); @@ -120,7 +120,7 @@ DoLU(void) exit(1); } - bbase = realloc(bbase, sizeof(double) * LUARRAYROWS*(i+1)); + bbase = realloc(bbase, sizeof(double) * LUARRAYROWS * (num_arrays + 1)); if (!bbase) { fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); free(a); @@ -129,11 +129,8 @@ DoLU(void) free(LUtempvv); exit(1); } - if(DoLUIteration(a,b,abase,bbase,i)>MINIMUM_TICKS) - { num_arrays=i; - break; - } - } + } while ((DoLUIteration(a, b, abase, bbase, num_arrays) <= MINIMUM_TICKS) && (num_arrays <= ARRAY_MAX)); + /* ** Were we able to do it? */ @@ -151,7 +148,7 @@ DoLU(void) ** Don't need to adjust -- just allocate the proper ** number of arrays and proceed. */ - abase = malloc(sizeof(double) * LUARRAYCOLS*LUARRAYROWS*num_arrays); + abase = malloc(sizeof(double) * LUARRAYCOLS * LUARRAYROWS * num_arrays); if (!abase) { fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); free(a); @@ -160,7 +157,7 @@ DoLU(void) exit(1); } - bbase = malloc(sizeof(double) * LUARRAYROWS*num_arrays); + bbase = malloc(sizeof(double) * LUARRAYROWS * num_arrays); if (!bbase) { fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); free(a); |