-/* $OpenBSD: output.c,v 1.16 2012/03/03 19:15:00 nicm Exp $ */
+/* $OpenBSD: output.c,v 1.17 2014/01/08 21:40:25 millert Exp $ */
/* $NetBSD: output.c,v 1.4 1996/03/19 03:21:41 jtc Exp $ */
/*
width = NEW2(nvectors, short);
token_actions();
- FREE(lookaheads);
- FREE(LA);
- FREE(LAruleno);
- FREE(accessing_symbol);
+ free(lookaheads);
+ free(LA);
+ free(LAruleno);
+ free(accessing_symbol);
goto_actions();
- FREE(goto_map + ntokens);
- FREE(from_state);
- FREE(to_state);
+ free(goto_map + ntokens);
+ free(from_state);
+ free(to_state);
sort_actions();
pack_table();
}
}
}
- FREE(actionrow);
+ free(actionrow);
}
void
if (!rflag) outline += 2;
fprintf(output_file, "\n};\n");
- FREE(state_count);
+ free(state_count);
}
int
for (i = 0; i < nvectors; i++)
{
if (froms[i])
- FREE(froms[i]);
+ free(froms[i]);
if (tos[i])
- FREE(tos[i]);
+ free(tos[i]);
}
- FREE(froms);
- FREE(tos);
- FREE(pos);
+ free(froms);
+ free(tos);
+ free(pos);
}
newmax = maxtable;
do { newmax += 200; } while (newmax <= loc);
- table = (short *) REALLOC(table, newmax*sizeof(short));
+ table = (short *) realloc(table, newmax*sizeof(short));
if (table == 0) no_space();
- check = (short *) REALLOC(check, newmax*sizeof(short));
+ check = (short *) realloc(check, newmax*sizeof(short));
if (check == 0) no_space();
for (l = maxtable; l < newmax; ++l)
{
if (!rflag) outline += 2;
fprintf(output_file, "\n};\n");
- FREE(base);
+ free(base);
}
if (!rflag) outline += 2;
fprintf(output_file, "\n};\n");
- FREE(table);
+ free(table);
}
if (!rflag) outline += 2;
fprintf(output_file, "\n};\n");
- FREE(check);
+ free(check);
}
++outline;
fprintf(code_file, "#define YYMAXTOKEN %d\n", max);
- symnam = (char **) MALLOC((max+1)*sizeof(char *));
+ symnam = (char **) malloc((max+1)*sizeof(char *));
if (symnam == 0) no_space();
/* Note that it is not necessary to initialize the element */
}
if (!rflag) outline += 2;
fprintf(output_file, "\n};\n");
- FREE(symnam);
+ free(symnam);
if (!rflag) ++outline;
fprintf(output_file,
{
core *cp, *next;
- FREE(state_table);
+ free(state_table);
for (cp = first_state; cp; cp = next)
{
next = cp->next;
- FREE(cp);
+ free(cp);
}
}
{
shifts *sp, *next;
- FREE(shift_table);
+ free(shift_table);
for (sp = first_shift; sp; sp = next)
{
next = sp->next;
- FREE(sp);
+ free(sp);
}
}
{
reductions *rp, *next;
- FREE(reduction_table);
+ free(reduction_table);
for (rp = first_reduction; rp; rp = next)
{
next = rp->next;
- FREE(rp);
+ free(rp);
}
}
-/* $OpenBSD: reader.c,v 1.23 2012/04/15 12:44:38 chl Exp $ */
+/* $OpenBSD: reader.c,v 1.24 2014/01/08 21:40:25 millert Exp $ */
/* $NetBSD: reader.c,v 1.5 1996/03/19 03:21:43 jtc Exp $ */
/*
if (cinc >= cache_size)
{
cache_size += 256;
- cache = REALLOC(cache, cache_size);
+ cache = realloc(cache, cache_size);
if (cache == NULL) no_space();
}
cache[cinc] = c;
if (saw_eof || (c = getc(f)) == EOF)
{
- if (line) { FREE(line); line = 0; }
+ if (line) { free(line); line = 0; }
cptr = 0;
saw_eof = 1;
return;
if (line == NULL || linesize != (LINESIZE + 1))
{
- if (line) FREE(line);
+ if (line) free(line);
linesize = LINESIZE + 1;
- line = MALLOC(linesize);
+ line = malloc(linesize);
if (line == NULL) no_space();
}
if (++i >= linesize)
{
linesize += LINESIZE;
- line = REALLOC(line, linesize);
+ line = realloc(line, linesize);
if (line == 0) no_space();
}
c = getc(f);
if (line == NULL) return (0);
s = line;
while (*s != '\n') ++s;
- p = MALLOC(s - line + 1);
+ p = malloc(s - line + 1);
if (p == NULL) no_space();
s = line;
if (*s == '*' && s[1] == '/')
{
cptr = s + 2;
- FREE(st_line);
+ free(st_line);
return;
}
if (*s == '\n')
if (c == quote)
{
need_newline = 1;
- FREE(s_line);
+ free(s_line);
goto loop;
}
if (c == '\n')
{
putc('/', f);
++cptr;
- FREE(c_line);
+ free(c_line);
goto loop;
}
if (c == '\n')
{
if (need_newline) putc('\n', f);
++cptr;
- FREE(t_line);
+ free(t_line);
return;
}
/* fall through */
{
fprintf(text_file, " YYSTYPE;\n");
fprintf(text_file, "#endif /* YYSTYPE_DEFINED */\n");
- FREE(u_line);
+ free(u_line);
return;
}
goto loop;
if (dflag) putc(c, union_file);
if (c == quote)
{
- FREE(s_line);
+ free(s_line);
goto loop;
}
if (c == '\n')
putc('/', text_file);
if (dflag) putc('/', union_file);
++cptr;
- FREE(c_line);
+ free(c_line);
goto loop;
}
if (c == '\n')
}
cachec(c);
}
- FREE(s_line);
+ free(s_line);
n = cinc;
- s = MALLOC(n);
+ s = malloc(n);
if (s == NULL) no_space();
memcpy(s, cache, n);
bp->class = TERM;
if (n == 1 && bp->value == UNDEFINED)
bp->value = *(unsigned char *)s;
- FREE(s);
+ free(s);
return (bp);
}
if (c == EOF) unexpected_EOF();
if (c != '>')
illegal_tag(t_lineno, t_line, t_cptr);
- FREE(t_line);
+ free(t_line);
++cptr;
for (i = 0; i < ntags; ++i)
{
tagmax += 16;
tag_table = (char **)
- (tag_table ? REALLOC(tag_table, tagmax*sizeof(char *))
- : MALLOC(tagmax*sizeof(char *)));
+ (tag_table ? realloc(tag_table, tagmax*sizeof(char *))
+ : malloc(tagmax*sizeof(char *)));
if (tag_table == NULL) no_space();
}
- s = MALLOC(cinc);
+ s = malloc(cinc);
if (s == NULL) no_space();
strlcpy(s, cache, cinc);
tag_table[ntags] = s;
int c, k;
cache_size = 256;
- cache = MALLOC(cache_size);
+ cache = malloc(cache_size);
if (cache == NULL) no_space();
for (;;)
{
nitems = 4;
maxitems = 300;
- pitem = (bucket **) CALLOC(maxitems, sizeof(bucket *));
+ pitem = (bucket **) calloc(maxitems, sizeof(bucket *));
if (pitem == NULL) no_space();
nrules = 3;
maxrules = 100;
- plhs = (bucket **) MALLOC(maxrules*sizeof(bucket *));
+ plhs = (bucket **) malloc(maxrules*sizeof(bucket *));
if (plhs == NULL) no_space();
plhs[0] = 0;
plhs[1] = 0;
plhs[2] = 0;
- rprec = (short *) MALLOC(maxrules*sizeof(short));
+ rprec = (short *) malloc(maxrules*sizeof(short));
if (rprec == NULL) no_space();
rprec[0] = 0;
rprec[1] = 0;
rprec[2] = 0;
- rassoc = (char *) MALLOC(maxrules*sizeof(char));
+ rassoc = (char *) malloc(maxrules*sizeof(char));
if (rassoc == NULL) no_space();
rassoc[0] = TOKEN;
rassoc[1] = TOKEN;
{
int olditems = maxitems;
maxitems += 300;
- pitem = (bucket **) REALLOC(pitem, maxitems*sizeof(bucket *));
+ pitem = (bucket **) realloc(pitem, maxitems*sizeof(bucket *));
if (pitem == NULL) no_space();
memset(pitem + olditems, 0, (maxitems - olditems)*sizeof(bucket *));
}
expand_rules(void)
{
maxrules += 100;
- plhs = (bucket **) REALLOC(plhs, maxrules*sizeof(bucket *));
+ plhs = (bucket **) realloc(plhs, maxrules*sizeof(bucket *));
if (plhs == NULL) no_space();
- rprec = (short *) REALLOC(rprec, maxrules*sizeof(short));
+ rprec = (short *) realloc(rprec, maxrules*sizeof(short));
if (rprec == NULL) no_space();
- rassoc = (char *) REALLOC(rassoc, maxrules*sizeof(char));
+ rassoc = (char *) realloc(rassoc, maxrules*sizeof(char));
if (rassoc == NULL) no_space();
}
{
fprintf(f, "yyval.%s", tag);
++cptr;
- FREE(d_line);
+ free(d_line);
goto loop;
}
else if (isdigit(c))
i = get_number();
if (i > n) dollar_warning(d_lineno, i);
fprintf(f, "yyvsp[%d].%s", i - n, tag);
- FREE(d_line);
+ free(d_line);
goto loop;
}
else if (c == '-' && isdigit(cptr[1]))
++cptr;
i = -get_number() - n;
fprintf(f, "yyvsp[%d].%s", i, tag);
- FREE(d_line);
+ free(d_line);
goto loop;
}
else
case ';':
if (depth > 0) goto loop;
fprintf(f, "\nbreak;\n");
- FREE(a_line);
+ free(a_line);
return;
case '{':
case '}':
if (--depth > 0) goto loop;
fprintf(f, "\nbreak;\n");
- FREE(a_line);
+ free(a_line);
return;
case '\'':
putc(c, f);
if (c == quote)
{
- FREE(s_line);
+ free(s_line);
goto loop;
}
if (c == '\n')
{
putc('/', f);
++cptr;
- FREE(c_line);
+ free(c_line);
goto loop;
}
if (c == '\n')
for (i = 0; i < ntags; ++i)
{
assert(tag_table[i]);
- FREE(tag_table[i]);
+ free(tag_table[i]);
}
- FREE(tag_table);
+ free(tag_table);
}
name_pool_size = 13; /* 13 == sizeof("$end") + sizeof("$accept") */
for (bp = first_symbol; bp; bp = bp->next)
name_pool_size += strlen(bp->name) + 1;
- name_pool = MALLOC(name_pool_size);
+ name_pool = malloc(name_pool_size);
if (name_pool == NULL) no_space();
strlcpy(name_pool, "$accept", name_pool_size);
p = t;
s = bp->name;
while ((*t++ = *s++)) continue;
- FREE(bp->name);
+ free(bp->name);
bp->name = p;
}
}
start_symbol = ntokens;
nvars = nsyms - ntokens;
- symbol_name = (char **) MALLOC(nsyms*sizeof(char *));
+ symbol_name = (char **) malloc(nsyms*sizeof(char *));
if (symbol_name == NULL) no_space();
- symbol_value = (short *) MALLOC(nsyms*sizeof(short));
+ symbol_value = (short *) malloc(nsyms*sizeof(short));
if (symbol_value == NULL) no_space();
- symbol_prec = (short *) MALLOC(nsyms*sizeof(short));
+ symbol_prec = (short *) malloc(nsyms*sizeof(short));
if (symbol_prec == NULL) no_space();
- symbol_assoc = MALLOC(nsyms);
+ symbol_assoc = malloc(nsyms);
if (symbol_assoc == NULL) no_space();
- v = (bucket **) MALLOC(nsyms*sizeof(bucket *));
+ v = (bucket **) malloc(nsyms*sizeof(bucket *));
if (v == NULL) no_space();
v[0] = 0;
symbol_assoc[k] = v[i]->assoc;
}
- FREE(v);
+ free(v);
}
int i, j;
int assoc, prec;
- ritem = (short *) MALLOC(nitems*sizeof(short));
+ ritem = (short *) malloc(nitems*sizeof(short));
if (ritem == NULL) no_space();
- rlhs = (short *) MALLOC(nrules*sizeof(short));
+ rlhs = (short *) malloc(nrules*sizeof(short));
if (rlhs == NULL) no_space();
- rrhs = (short *) MALLOC((nrules+1)*sizeof(short));
+ rrhs = (short *) malloc((nrules+1)*sizeof(short));
if (rrhs == NULL) no_space();
- rprec = (short *) REALLOC(rprec, nrules*sizeof(short));
+ rprec = (short *) realloc(rprec, nrules*sizeof(short));
if (rprec == NULL) no_space();
- rassoc = REALLOC(rassoc, nrules);
+ rassoc = realloc(rassoc, nrules);
if (rassoc == NULL) no_space();
ritem[0] = -1;
}
rrhs[i] = j;
- FREE(plhs);
- FREE(pitem);
+ free(plhs);
+ free(pitem);
}