summaryrefslogtreecommitdiff
path: root/assignment.c
diff options
context:
space:
mode:
Diffstat (limited to 'assignment.c')
-rw-r--r--assignment.c53
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);