* xmlStreamCompAddStep: * @comp: the compiled pattern for streaming * @name: the first string, the name, or NULL for * * @ns: the second step, the namespace name * @flags: the flags for that step * * Add a new step to the compiled pattern * * Returns -1 in case of error or the step index if successful */
| 1472 | * Returns -1 in case of error or the step index if successful |
| 1473 | */ |
| 1474 | static int |
| 1475 | xmlStreamCompAddStep(xmlStreamCompPtr comp, const xmlChar *name, |
| 1476 | const xmlChar *ns, int nodeType, int flags) { |
| 1477 | xmlStreamStepPtr cur; |
| 1478 | |
| 1479 | if (comp->nbStep >= comp->maxStep) { |
| 1480 | cur = (xmlStreamStepPtr) xmlRealloc(comp->steps, |
| 1481 | comp->maxStep * 2 * sizeof(xmlStreamStep)); |
| 1482 | if (cur == NULL) { |
| 1483 | ERROR(NULL, NULL, NULL, |
| 1484 | "xmlNewStreamComp: malloc failed\n"); |
| 1485 | return(-1); |
| 1486 | } |
| 1487 | comp->steps = cur; |
| 1488 | comp->maxStep *= 2; |
| 1489 | } |
| 1490 | cur = &comp->steps[comp->nbStep++]; |
| 1491 | cur->flags = flags; |
| 1492 | cur->name = name; |
| 1493 | cur->ns = ns; |
| 1494 | cur->nodeType = nodeType; |
| 1495 | return(comp->nbStep - 1); |
| 1496 | } |
| 1497 | |
| 1498 | /** |
| 1499 | * xmlStreamCompile: |