diff options
author | Matt Turner <mattst88@gmail.com> | 2008-11-13 22:07:24 +0000 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2008-11-13 22:07:24 +0000 |
commit | 8a9fd3f93bb3db2d969126913eedab023dba013f (patch) | |
tree | 5cd76353b5ec3e8be5c1062c0294e9b402a71487 /assignment.c | |
parent | 9631ec05f6ddc60b231e5fad280e5a5242c5bab3 (diff) |
Remove AllocateMemory, FreeMemory, MoveMemory, ErrorExit, and ReportError functions
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@17 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
Diffstat (limited to 'assignment.c')
-rw-r--r-- | assignment.c | 53 |
1 files changed, 13 insertions, 40 deletions
diff --git a/assignment.c b/assignment.c index 7d83507..d3598c5 100644 --- a/assignment.c +++ b/assignment.c @@ -67,24 +67,13 @@ static void second_assignments(long tableau[][ASSIGNCOLS], */ void DoAssign(void) { -AssignStruct *locassignstruct; /* Local structure ptr */ -long *arraybase; -char *errorcontext; -int systemerror; +AssignStruct *locassignstruct = &global_assignstruct; /* Local structure ptr */ +long *arraybase = NULL; +char *context = "CPU:Assignment"; unsigned long accumtime; double iterations; /* -** Link to global structure -*/ -locassignstruct=&global_assignstruct; - -/* -** Set the error context string. -*/ -errorcontext="CPU:Assignment"; - -/* ** See if we need to do self adjustment code. */ if(locassignstruct->adjust==0) @@ -98,17 +87,10 @@ if(locassignstruct->adjust==0) locassignstruct->numarrays=1; while(1) { - /* - ** Allocate space for arrays - */ - arraybase=(long *) AllocateMemory(sizeof(long)* - ASSIGNROWS*ASSIGNCOLS*locassignstruct->numarrays, - &systemerror); - if(systemerror) - { ReportError(errorcontext,systemerror); - FreeMemory((void *)arraybase, - &systemerror); - ErrorExit(); + arraybase = realloc(arraybase, sizeof(long) * ASSIGNROWS * ASSIGNCOLS * locassignstruct->numarrays); + if (!arraybase) { + fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); + exit(1); } /* @@ -121,22 +103,13 @@ if(locassignstruct->adjust==0) locassignstruct->numarrays)>global_min_ticks) break; /* We're ok...exit */ - FreeMemory((void *)arraybase, &systemerror); locassignstruct->numarrays++; } -} -else -{ /* - ** Allocate space for arrays - */ - arraybase=(long *)AllocateMemory(sizeof(long)* - ASSIGNROWS*ASSIGNCOLS*locassignstruct->numarrays, - &systemerror); - if(systemerror) - { ReportError(errorcontext,systemerror); - FreeMemory((void *)arraybase, - &systemerror); - ErrorExit(); +} else { + arraybase = malloc(sizeof(long) * ASSIGNROWS * ASSIGNCOLS * locassignstruct->numarrays); + if (!arraybase) { + fprintf(stderr, "Error in %s, could not allocate memory. Exitting...\n", context); + exit(1); } } @@ -156,7 +129,7 @@ do { ** Clean up, calculate results, and go home. Be sure to ** show that we don't have to rerun adjustment code. */ -FreeMemory((void *)arraybase,&systemerror); +free(arraybase); locassignstruct->iterspersec=iterations * (double)locassignstruct->numarrays / TicksToFracSecs(accumtime); |