diff options
Diffstat (limited to 'contrib/byacc/reader.c')
-rw-r--r-- | contrib/byacc/reader.c | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/contrib/byacc/reader.c b/contrib/byacc/reader.c index d41e92a..6b24d7d 100644 --- a/contrib/byacc/reader.c +++ b/contrib/byacc/reader.c @@ -1,4 +1,4 @@ -/* $Id: reader.c,v 1.33 2011/09/06 22:56:53 tom Exp $ */ +/* $Id: reader.c,v 1.36 2012/05/26 16:05:41 tom Exp $ */ #include "defs.h" @@ -52,7 +52,7 @@ cachec(int c) if (cinc >= cache_size) { cache_size += 256; - cache = REALLOC(cache, cache_size); + cache = TREALLOC(char, cache, cache_size); NO_SPACE(cache); } cache[cinc] = (char)c; @@ -83,7 +83,7 @@ get_line(void) if (line) FREE(line); linesize = LINESIZE + 1; - line = MALLOC(linesize); + line = TMALLOC(char, linesize); NO_SPACE(line); } @@ -100,7 +100,7 @@ get_line(void) if (++i >= linesize) { linesize += LINESIZE; - line = REALLOC(line, linesize); + line = TREALLOC(char, line, linesize); NO_SPACE(line); } c = getc(f); @@ -124,7 +124,7 @@ dup_line(void) s = line; while (*s != '\n') ++s; - p = MALLOC(s - line + 1); + p = TMALLOC(char, s - line + 1); NO_SPACE(p); s = line; @@ -685,7 +685,7 @@ copy_param(int k) if (c == '}') goto out; - buf = MALLOC(linesize); + buf = TMALLOC(char, linesize); NO_SPACE(buf); for (i = 0; (c = *cptr++) != '}'; i++) @@ -733,7 +733,7 @@ copy_param(int k) name = i + 1; - p = MALLOC(sizeof(*p)); + p = TMALLOC(param, 1); NO_SPACE(p); p->type2 = strdup(buf + type2); @@ -890,7 +890,7 @@ get_literal(void) FREE(s_line); n = cinc; - s = MALLOC(n); + s = TMALLOC(char, n); NO_SPACE(s); for (i = 0; i < n; ++i) @@ -1058,14 +1058,14 @@ get_tag(void) if (ntags >= tagmax) { tagmax += 16; - tag_table = (char **) + tag_table = (tag_table - ? REALLOC(tag_table, (unsigned)tagmax * sizeof(char *)) - : MALLOC((unsigned)tagmax * sizeof(char *))); + ? TREALLOC(char *, tag_table, tagmax) + : TMALLOC(char *, tagmax)); NO_SPACE(tag_table); } - s = MALLOC(cinc); + s = TMALLOC(char, cinc); NO_SPACE(s); strcpy(s, cache); @@ -1246,7 +1246,7 @@ read_declarations(void) int c, k; cache_size = 256; - cache = MALLOC(cache_size); + cache = TMALLOC(char, cache_size); NO_SPACE(cache); for (;;) @@ -1316,7 +1316,7 @@ initialize_grammar(void) nitems = 4; maxitems = 300; - pitem = (bucket **)MALLOC((unsigned)maxitems * sizeof(bucket *)); + pitem = TMALLOC(bucket *, maxitems); NO_SPACE(pitem); pitem[0] = 0; @@ -1327,21 +1327,21 @@ initialize_grammar(void) nrules = 3; maxrules = 100; - plhs = (bucket **)MALLOC((unsigned)maxrules * sizeof(bucket *)); + plhs = TMALLOC(bucket *, maxrules); NO_SPACE(plhs); plhs[0] = 0; plhs[1] = 0; plhs[2] = 0; - rprec = (short *)MALLOC((unsigned)maxrules * sizeof(short)); + rprec = TMALLOC(Value_t, maxrules); NO_SPACE(rprec); rprec[0] = 0; rprec[1] = 0; rprec[2] = 0; - rassoc = (char *)MALLOC((unsigned)maxrules * sizeof(char)); + rassoc = TMALLOC(Assoc_t, maxrules); NO_SPACE(rassoc); rassoc[0] = TOKEN; @@ -1353,7 +1353,7 @@ static void expand_items(void) { maxitems += 300; - pitem = (bucket **)REALLOC(pitem, (unsigned)maxitems * sizeof(bucket *)); + pitem = TREALLOC(bucket *, pitem, maxitems); NO_SPACE(pitem); } @@ -1362,13 +1362,13 @@ expand_rules(void) { maxrules += 100; - plhs = (bucket **)REALLOC(plhs, (unsigned)maxrules * sizeof(bucket *)); + plhs = TREALLOC(bucket *, plhs, maxrules); NO_SPACE(plhs); - rprec = (short *)REALLOC(rprec, (unsigned)maxrules * sizeof(short)); + rprec = TREALLOC(Value_t, rprec, maxrules); NO_SPACE(rprec); - rassoc = (char *)REALLOC(rassoc, (unsigned)maxrules * sizeof(char)); + rassoc = TREALLOC(Assoc_t, rassoc, maxrules); NO_SPACE(rassoc); } @@ -1780,9 +1780,7 @@ static int mark_symbol(void) { int c; - bucket *bp; - - bp = NULL; + bucket *bp = NULL; c = cptr[1]; if (c == '%' || c == '\\') @@ -1886,7 +1884,7 @@ pack_names(void) for (bp = first_symbol; bp; bp = bp->next) name_pool_size += strlen(bp->name) + 1; - name_pool = MALLOC(name_pool_size); + name_pool = TMALLOC(char, name_pool_size); NO_SPACE(name_pool); strcpy(name_pool, "$accept"); @@ -1941,7 +1939,7 @@ protect_string(char *src, char **des) len++; } - *des = d = (char *)MALLOC(len); + *des = d = TMALLOC(char, len); NO_SPACE(d); s = src; @@ -1973,19 +1971,19 @@ pack_symbols(void) start_symbol = (Value_t) ntokens; nvars = nsyms - ntokens; - symbol_name = (char **)MALLOC((unsigned)nsyms * sizeof(char *)); + symbol_name = TMALLOC(char *, nsyms); NO_SPACE(symbol_name); - symbol_value = (short *)MALLOC((unsigned)nsyms * sizeof(short)); + symbol_value = TMALLOC(Value_t, nsyms); NO_SPACE(symbol_value); - symbol_prec = (short *)MALLOC((unsigned)nsyms * sizeof(short)); + symbol_prec = TMALLOC(short, nsyms); NO_SPACE(symbol_prec); - symbol_assoc = MALLOC(nsyms); + symbol_assoc = TMALLOC(char, nsyms); NO_SPACE(symbol_assoc); - v = (bucket **)MALLOC((unsigned)nsyms * sizeof(bucket *)); + v = TMALLOC(bucket *, nsyms); NO_SPACE(v); v[0] = 0; @@ -2085,7 +2083,7 @@ pack_symbols(void) if (gflag) { - symbol_pname = (char **)MALLOC((unsigned)nsyms * sizeof(char *)); + symbol_pname = TMALLOC(char *, nsyms); NO_SPACE(symbol_pname); for (i = 0; i < nsyms; ++i) @@ -2103,19 +2101,19 @@ pack_grammar(void) Assoc_t assoc; Value_t prec2; - ritem = (short *)MALLOC((unsigned)nitems * sizeof(short)); + ritem = TMALLOC(Value_t, nitems); NO_SPACE(ritem); - rlhs = (short *)MALLOC((unsigned)nrules * sizeof(short)); + rlhs = TMALLOC(Value_t, nrules); NO_SPACE(rlhs); - rrhs = (short *)MALLOC((unsigned)(nrules + 1) * sizeof(short)); + rrhs = TMALLOC(Value_t, nrules + 1); NO_SPACE(rrhs); - rprec = (short *)REALLOC(rprec, (unsigned)nrules * sizeof(short)); + rprec = TREALLOC(Value_t, rprec, nrules); NO_SPACE(rprec); - rassoc = REALLOC(rassoc, nrules); + rassoc = TREALLOC(Assoc_t, rassoc, nrules); NO_SPACE(rassoc); ritem[0] = -1; |