Ticket #270: stream.C.diff

File stream.C.diff, 1.4 KB (added by Joses, 17 years ago)

diff against latest stream.C of June 13, 2007

  • stream.C

    old new  
    9797  double  *a=(double *)malloc((N+OFFSET)*sizeof(double));
    9898  double  *b=(double *)malloc((N+OFFSET)*sizeof(double));
    9999  double  *c=(double *)malloc((N+OFFSET)*sizeof(double));
     100  double  *at, bt, ct;
    100101  double   quantum=checktick();
    101102  int   BytesPerWord;
    102103  register int j, k;
     
    109110  int i=0;
    110111
    111112  int check_cache=(cache_size==0);
     113  if ( !a || !b || !c ) {
     114    if ( a ) free(a);
     115    if ( b ) free(b);
     116    if ( c ) free(c);
     117    return;
     118  }
    112119  do {
    113120    N*=2;
    114     a=(double *)realloc(a,(N+OFFSET)*sizeof(double));
    115     b=(double *)realloc(b,(N+OFFSET)*sizeof(double));
    116     c=(double *)realloc(c,(N+OFFSET)*sizeof(double));
    117     if ( !a || !b || !c ) return;
     121    at=(double *)realloc(a,(N+OFFSET)*sizeof(double));
     122    bt=(double *)realloc(b,(N+OFFSET)*sizeof(double));
     123    ct=(double *)realloc(c,(N+OFFSET)*sizeof(double));
     124    /* exit if not enough memory reallocated */
     125    if ( at ) a = at;
     126    if ( bt ) b = bt;
     127    if ( ct ) c = ct;
     128    if ( !at || !bt || !ct ) {
     129      free(a);
     130      free(b);
     131      free(c);
     132      return;
     133    }
    118134
    119135    for (j=0; j<N; j++) {
    120136      a[j] = 1.0;
     
    211227  /* --- Check Results --- */
    212228  checkSTREAMresults(a,b,c);
    213229
     230  free(a);
     231  free(b);
     232  free(c);
    214233}
    215234
    216235# define M 20