mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 23:33:03 +00:00
* src/system.h (CALLOC, MALLOC, REALLOC): Remove. All callers
changed to use xcalloc, xnmalloc, xnrealloc, respectively, unless otherwise specified below. * src/LR0.c (allocate_itemsets): Use xnmalloc, not xcalloc, to allocate kernel_base, kernel_items, kernel_size, since they needn't be initialized to 0. (allocate_storgae): Likewise, for shiftset, redset, shift_symbol. * src/closure.c (new_closure): Likewise, for itemset. * src/derives.c (derives_compute): Likewise, for delts, derives, q. * src/lalr.c (set_goto_map): Likewise, for temp_map. (initialize_F): Likewise, for reads, edge, reads[i], includes[i]. (build_relations): Likewise for edge, states1, includes. * src/nullable.c (nullable_compute): Likewise, for squeue, relts. * src/reader.c (packgram): Likewise, for ritem, rules. * src/reduce.c (nonterminals_reduce): Likewise for nontermmap. * src/relation.c (relation_digraph): Likewise for VERTICES. (relation_transpose): Likewise for new_R, end_R. * src/symtab.c (symbols_token_translations_init): Likewise for token_translations. * src/tables.c (save_row): Likewise for froms, tos, conflict_tos. (token_actions): Likewise for yydefact, actrow, conflrow, conflict_list. (save_column): Likewise for froms[symno], tos[symno]. (goto_actions): Likewise for state_count. (pack_table): Likewise for base, pos, check. (tables_generate): Likewise for width. * src/LR0.c (set_states): Don't reuse kernel_size and kernel_base for initial core. Just have a separate core, so we needn't worry about whether kernel_size and kernel_base are initialized. * src/LR0.c (shift_symbol, redset, shiftset, kernel_base, kernel_size, kernel_items): Remove unnecessary initialization. * src/conflicts.c (conflicts): Likewise. * src/derives.c (derives): Likewise. * src/muscle_tablc (muscle_insert): Likewise. * src/relation.c (relation_digraph): Likewise. * src/tables.c (froms, tos, conflict_tos, tally, width, actrow, order, conflrow, conflict_table, conflict_list, table, check): Likewise. * src/closure.c (new_closure): Arg is of type unsigned int, not int. This is because all callers pass unsigned int. * src/closure.h (new_closure): Likewise. * src/lalr.c (initialize_F): Initialize reads[i] in all cases. (build_relations): Initialize includes[i] in all cases. * src/reader.c (packgram): Always initialize rules[ruleno].prec and rules[ruleno].precsym. Initialize members in order. * src/relation.c (relation_transpose): Always initialize new_R[i] and end_R[i]. * src/table.c (conflict_row): Initialize 0 at end of conflict_list. * src/output.c (prepare_actions): Pass 0 instead of conflict_list[0]; conflict_list[0] was always 0, but now it isn't initialized. * src/table.c (table_grow): When conflict_table grew, the grown area wasn't cleared. Fix this.
This commit is contained in:
36
src/lalr.c
36
src/lalr.c
@@ -80,8 +80,8 @@ set_goto_map (void)
|
||||
state_number s;
|
||||
goto_number *temp_map;
|
||||
|
||||
CALLOC (goto_map, nvars + 1);
|
||||
CALLOC (temp_map, nvars + 1);
|
||||
goto_map = xcalloc (nvars + 1, sizeof *goto_map);
|
||||
temp_map = xnmalloc (nvars + 1, sizeof *temp_map);
|
||||
|
||||
ngotos = 0;
|
||||
for (s = 0; s < nstates; ++s)
|
||||
@@ -116,8 +116,8 @@ set_goto_map (void)
|
||||
temp_map[nsyms - ntokens] = ngotos;
|
||||
}
|
||||
|
||||
CALLOC (from_state, ngotos);
|
||||
CALLOC (to_state, ngotos);
|
||||
from_state = xcalloc (ngotos, sizeof *from_state);
|
||||
to_state = xcalloc (ngotos, sizeof *to_state);
|
||||
|
||||
for (s = 0; s < nstates; ++s)
|
||||
{
|
||||
@@ -170,8 +170,8 @@ map_goto (state_number s0, symbol_number sym)
|
||||
static void
|
||||
initialize_F (void)
|
||||
{
|
||||
goto_number **reads = CALLOC (reads, ngotos);
|
||||
goto_number *edge = CALLOC (edge, ngotos + 1);
|
||||
goto_number **reads = xnmalloc (ngotos, sizeof *reads);
|
||||
goto_number *edge = xnmalloc (ngotos + 1, sizeof *edge);
|
||||
goto_number nedges = 0;
|
||||
|
||||
goto_number i;
|
||||
@@ -194,10 +194,12 @@ initialize_F (void)
|
||||
edge[nedges++] = map_goto (stateno, sym);
|
||||
}
|
||||
|
||||
if (nedges)
|
||||
if (nedges == 0)
|
||||
reads[i] = NULL;
|
||||
else
|
||||
{
|
||||
CALLOC (reads[i], nedges + 1);
|
||||
memcpy (reads[i], edge, nedges * sizeof (edge[0]));
|
||||
reads[i] = xnmalloc (nedges + 1, sizeof reads[i][0]);
|
||||
memcpy (reads[i], edge, nedges * sizeof edge[0]);
|
||||
reads[i][nedges] = END_NODE;
|
||||
nedges = 0;
|
||||
}
|
||||
@@ -217,7 +219,7 @@ static void
|
||||
add_lookback_edge (state *s, rule *r, goto_number gotono)
|
||||
{
|
||||
int ri = state_reduction_find (s, r);
|
||||
goto_list *sp = MALLOC (sp, 1);
|
||||
goto_list *sp = xmalloc (sizeof *sp);
|
||||
sp->next = lookback[(s->reductions->look_ahead_tokens - LA) + ri];
|
||||
sp->value = gotono;
|
||||
lookback[(s->reductions->look_ahead_tokens - LA) + ri] = sp;
|
||||
@@ -228,11 +230,11 @@ add_lookback_edge (state *s, rule *r, goto_number gotono)
|
||||
static void
|
||||
build_relations (void)
|
||||
{
|
||||
goto_number *edge = CALLOC (edge, ngotos + 1);
|
||||
state_number *states1 = CALLOC (states1, ritem_longest_rhs () + 1);
|
||||
goto_number *edge = xnmalloc (ngotos + 1, sizeof *edge);
|
||||
state_number *states1 = xnmalloc (ritem_longest_rhs () + 1, sizeof *states1);
|
||||
goto_number i;
|
||||
|
||||
CALLOC (includes, ngotos);
|
||||
includes = xnmalloc (ngotos, sizeof *includes);
|
||||
|
||||
for (i = 0; i < ngotos; i++)
|
||||
{
|
||||
@@ -276,10 +278,12 @@ build_relations (void)
|
||||
}
|
||||
}
|
||||
|
||||
if (nedges)
|
||||
if (nedges == 0)
|
||||
includes[i] = NULL;
|
||||
else
|
||||
{
|
||||
int j;
|
||||
CALLOC (includes[i], nedges + 1);
|
||||
includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
|
||||
for (j = 0; j < nedges; j++)
|
||||
includes[i][j] = edge[j];
|
||||
includes[i][nedges] = END_NODE;
|
||||
@@ -381,7 +385,7 @@ initialize_LA (void)
|
||||
nLA = 1;
|
||||
|
||||
pLA = LA = bitsetv_create (nLA, ntokens, BITSET_FIXED);
|
||||
CALLOC (lookback, nLA);
|
||||
lookback = xcalloc (nLA, sizeof *lookback);
|
||||
|
||||
/* Initialize the members LOOK_AHEAD_TOKENS for each state whose reductions
|
||||
require look-ahead tokens. */
|
||||
|
||||
Reference in New Issue
Block a user