[BACK]Return to reader.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / yacc

Diff for /src/usr.bin/yacc/reader.c between version 1.28 and 1.29

version 1.28, 2014/03/13 01:18:22 version 1.29, 2014/10/09 03:02:18
Line 868 
Line 868 
   
         if (ntags >= tagmax) {          if (ntags >= tagmax) {
                 tagmax += 16;                  tagmax += 16;
                 tag_table = (tag_table ?                  tag_table = reallocarray(tag_table, tagmax, sizeof(char *));
                     realloc(tag_table, tagmax * sizeof(char *)) :  
                     malloc(tagmax * sizeof(char *)));  
                 if (tag_table == NULL)                  if (tag_table == NULL)
                         no_space();                          no_space();
         }          }
Line 1100 
Line 1098 
   
         nrules = 3;          nrules = 3;
         maxrules = 100;          maxrules = 100;
         plhs = malloc(maxrules * sizeof(bucket *));          plhs = reallocarray(NULL, maxrules, sizeof(bucket *));
         if (plhs == NULL)          if (plhs == NULL)
                 no_space();                  no_space();
         plhs[0] = 0;          plhs[0] = 0;
         plhs[1] = 0;          plhs[1] = 0;
         plhs[2] = 0;          plhs[2] = 0;
         rprec = malloc(maxrules * sizeof(short));          rprec = reallocarray(NULL, maxrules, sizeof(short));
         if (rprec == NULL)          if (rprec == NULL)
                 no_space();                  no_space();
         rprec[0] = 0;          rprec[0] = 0;
         rprec[1] = 0;          rprec[1] = 0;
         rprec[2] = 0;          rprec[2] = 0;
         rassoc = malloc(maxrules * sizeof(char));          rassoc = reallocarray(NULL, maxrules, sizeof(char));
         if (rassoc == NULL)          if (rassoc == NULL)
                 no_space();                  no_space();
         rassoc[0] = TOKEN;          rassoc[0] = TOKEN;
Line 1127 
Line 1125 
         int olditems = maxitems;          int olditems = maxitems;
   
         maxitems += 300;          maxitems += 300;
         pitem = realloc(pitem, maxitems * sizeof(bucket *));          pitem = reallocarray(pitem, maxitems, sizeof(bucket *));
         if (pitem == NULL)          if (pitem == NULL)
                 no_space();                  no_space();
         memset(pitem + olditems, 0, (maxitems - olditems) * sizeof(bucket *));          memset(pitem + olditems, 0, (maxitems - olditems) * sizeof(bucket *));
Line 1138 
Line 1136 
 expand_rules(void)  expand_rules(void)
 {  {
         maxrules += 100;          maxrules += 100;
         plhs = realloc(plhs, maxrules * sizeof(bucket *));          plhs = reallocarray(plhs, maxrules, sizeof(bucket *));
         if (plhs == NULL)          if (plhs == NULL)
                 no_space();                  no_space();
         rprec = realloc(rprec, maxrules * sizeof(short));          rprec = reallocarray(rprec, maxrules, sizeof(short));
         if (rprec == NULL)          if (rprec == NULL)
                 no_space();                  no_space();
         rassoc = realloc(rassoc, maxrules * sizeof(char));          rassoc = reallocarray(rassoc, maxrules, sizeof(char));
         if (rassoc == NULL)          if (rassoc == NULL)
                 no_space();                  no_space();
 }  }
Line 1643 
Line 1641 
         start_symbol = ntokens;          start_symbol = ntokens;
         nvars = nsyms - ntokens;          nvars = nsyms - ntokens;
   
         symbol_name = malloc(nsyms * sizeof(char *));          symbol_name = reallocarray(NULL, nsyms, sizeof(char *));
         if (symbol_name == NULL)          if (symbol_name == NULL)
                 no_space();                  no_space();
         symbol_value = malloc(nsyms * sizeof(short));          symbol_value = reallocarray(NULL, nsyms, sizeof(short));
         if (symbol_value == NULL)          if (symbol_value == NULL)
                 no_space();                  no_space();
         symbol_prec = malloc(nsyms * sizeof(short));          symbol_prec = reallocarray(NULL, nsyms, sizeof(short));
         if (symbol_prec == NULL)          if (symbol_prec == NULL)
                 no_space();                  no_space();
         symbol_assoc = malloc(nsyms);          symbol_assoc = malloc(nsyms);
         if (symbol_assoc == NULL)          if (symbol_assoc == NULL)
                 no_space();                  no_space();
   
         v = malloc(nsyms * sizeof(bucket *));          v = reallocarray(NULL, nsyms, sizeof(bucket *));
         if (v == NULL)          if (v == NULL)
                 no_space();                  no_space();
   
Line 1751 
Line 1749 
         int i, j;          int i, j;
         int assoc, prec;          int assoc, prec;
   
         ritem = malloc(nitems * sizeof(short));          ritem = reallocarray(NULL, nitems, sizeof(short));
         if (ritem == NULL)          if (ritem == NULL)
                 no_space();                  no_space();
         rlhs = malloc(nrules * sizeof(short));          rlhs = reallocarray(NULL, nrules, sizeof(short));
         if (rlhs == NULL)          if (rlhs == NULL)
                 no_space();                  no_space();
         rrhs = malloc((nrules + 1) * sizeof(short));          rrhs = reallocarray(NULL, nrules + 1, sizeof(short));
         if (rrhs == NULL)          if (rrhs == NULL)
                 no_space();                  no_space();
         rprec = realloc(rprec, nrules * sizeof(short));          rprec = reallocarray(rprec, nrules, sizeof(short));
         if (rprec == NULL)          if (rprec == NULL)
                 no_space();                  no_space();
         rassoc = realloc(rassoc, nrules);          rassoc = realloc(rassoc, nrules);

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29