MCPcopy Create free account
hub / github.com/git/git / register_state

Function register_state

compat/regex/regex_internal.c:1571–1604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1569
1570/* Finish initialization of the new state NEWSTATE, and using its hash value
1571 HASH put in the appropriate bucket of DFA's state table. Return value
1572 indicates the error code if failed. */
1573
1574static reg_errcode_t
1575register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
1576 unsigned int hash)
1577{
1578 struct re_state_table_entry *spot;
1579 reg_errcode_t err;
1580 int i;
1581
1582 newstate->hash = hash;
1583 err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem);
1584 if (BE (err != REG_NOERROR, 0))
1585 return REG_ESPACE;
1586 for (i = 0; i < newstate->nodes.nelem; i++)
1587 {
1588 int elem = newstate->nodes.elems[i];
1589 if (!IS_EPSILON_NODE (dfa->nodes[elem].type))
1590 if (re_node_set_insert_last (&newstate->non_eps_nodes, elem) < 0)
1591 return REG_ESPACE;
1592 }
1593
1594 spot = dfa->state_table + (hash & dfa->state_hash_mask);
1595 if (BE (spot->alloc <= spot->num, 0))
1596 {
1597 int new_alloc = 2 * spot->num + 2;
1598 re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *,
1599 new_alloc);
1600 if (BE (new_array == NULL, 0))
1601 return REG_ESPACE;
1602 spot->array = new_array;
1603 spot->alloc = new_alloc;
1604 }
1605 spot->array[spot->num++] = newstate;
1606 return REG_NOERROR;
1607}

Callers 2

create_ci_newstateFunction · 0.85
create_cd_newstateFunction · 0.85

Calls 2

re_node_set_allocFunction · 0.85
re_node_set_insert_lastFunction · 0.85

Tested by

no test coverage detected