MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlRegStateAddTrans

Function xmlRegStateAddTrans

ThirdParty/libxml2/vtklibxml2/xmlregexp.c:1290–1350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1288}
1289
1290static void
1291xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
1292 xmlRegAtomPtr atom, xmlRegStatePtr target,
1293 int counter, int count) {
1294
1295 int nrtrans;
1296
1297 if (state == NULL) {
1298 ERROR("add state: state is NULL");
1299 return;
1300 }
1301 if (target == NULL) {
1302 ERROR("add state: target is NULL");
1303 return;
1304 }
1305 /*
1306 * Other routines follow the philosophy 'When in doubt, add a transition'
1307 * so we check here whether such a transition is already present and, if
1308 * so, silently ignore this request.
1309 */
1310
1311 for (nrtrans = state->nbTrans - 1; nrtrans >= 0; nrtrans--) {
1312 xmlRegTransPtr trans = &(state->trans[nrtrans]);
1313 if ((trans->atom == atom) &&
1314 (trans->to == target->no) &&
1315 (trans->counter == counter) &&
1316 (trans->count == count)) {
1317 return;
1318 }
1319 }
1320
1321 if (state->maxTrans == 0) {
1322 state->maxTrans = 8;
1323 state->trans = (xmlRegTrans *) xmlMalloc(state->maxTrans *
1324 sizeof(xmlRegTrans));
1325 if (state->trans == NULL) {
1326 xmlRegexpErrMemory(ctxt);
1327 state->maxTrans = 0;
1328 return;
1329 }
1330 } else if (state->nbTrans >= state->maxTrans) {
1331 xmlRegTrans *tmp;
1332 state->maxTrans *= 2;
1333 tmp = (xmlRegTrans *) xmlRealloc(state->trans, state->maxTrans *
1334 sizeof(xmlRegTrans));
1335 if (tmp == NULL) {
1336 xmlRegexpErrMemory(ctxt);
1337 state->maxTrans /= 2;
1338 return;
1339 }
1340 state->trans = tmp;
1341 }
1342
1343 state->trans[state->nbTrans].atom = atom;
1344 state->trans[state->nbTrans].to = target->no;
1345 state->trans[state->nbTrans].counter = counter;
1346 state->trans[state->nbTrans].count = count;
1347 state->trans[state->nbTrans].nd = 0;

Calls 2

xmlRegexpErrMemoryFunction · 0.85
xmlRegStateAddTransToFunction · 0.85

Tested by

no test coverage detected