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

Function xmlXPathCompExprAdd

ThirdParty/libxml2/vtklibxml2/xpath.c:976–1026  ·  view source on GitHub ↗

* xmlXPathCompExprAdd: * @comp: the compiled expression * @ch1: first child index * @ch2: second child index * @op: an op * @value: the first int value * @value2: the second int value * @value3: the third int value * @value4: the first string value * @value5: the second string value * * Add a step to an XPath Compiled Expression * * Returns -1 in case of failure, the index othe

Source from the content-addressed store, hash-verified

974 * Returns -1 in case of failure, the index otherwise
975 */
976static int
977xmlXPathCompExprAdd(xmlXPathParserContextPtr ctxt, int ch1, int ch2,
978 xmlXPathOp op, int value,
979 int value2, int value3, void *value4, void *value5) {
980 xmlXPathCompExprPtr comp = ctxt->comp;
981 if (comp->nbStep >= comp->maxStep) {
982 xmlXPathStepOp *real;
983
984 if (comp->maxStep >= XPATH_MAX_STEPS) {
985 xmlXPathPErrMemory(ctxt);
986 return(-1);
987 }
988 comp->maxStep *= 2;
989 real = (xmlXPathStepOp *) xmlRealloc(comp->steps,
990 comp->maxStep * sizeof(xmlXPathStepOp));
991 if (real == NULL) {
992 comp->maxStep /= 2;
993 xmlXPathPErrMemory(ctxt);
994 return(-1);
995 }
996 comp->steps = real;
997 }
998 comp->last = comp->nbStep;
999 comp->steps[comp->nbStep].ch1 = ch1;
1000 comp->steps[comp->nbStep].ch2 = ch2;
1001 comp->steps[comp->nbStep].op = op;
1002 comp->steps[comp->nbStep].value = value;
1003 comp->steps[comp->nbStep].value2 = value2;
1004 comp->steps[comp->nbStep].value3 = value3;
1005 if ((comp->dict != NULL) &&
1006 ((op == XPATH_OP_FUNCTION) || (op == XPATH_OP_VARIABLE) ||
1007 (op == XPATH_OP_COLLECT))) {
1008 if (value4 != NULL) {
1009 comp->steps[comp->nbStep].value4 = (xmlChar *)
1010 (void *)xmlDictLookup(comp->dict, value4, -1);
1011 xmlFree(value4);
1012 } else
1013 comp->steps[comp->nbStep].value4 = NULL;
1014 if (value5 != NULL) {
1015 comp->steps[comp->nbStep].value5 = (xmlChar *)
1016 (void *)xmlDictLookup(comp->dict, value5, -1);
1017 xmlFree(value5);
1018 } else
1019 comp->steps[comp->nbStep].value5 = NULL;
1020 } else {
1021 comp->steps[comp->nbStep].value4 = value4;
1022 comp->steps[comp->nbStep].value5 = value5;
1023 }
1024 comp->steps[comp->nbStep].cache = NULL;
1025 return(comp->nbStep++);
1026}
1027
1028/**
1029 * xmlXPathCompSwap:

Callers

nothing calls this directly

Calls 2

xmlXPathPErrMemoryFunction · 0.85
xmlDictLookupFunction · 0.85

Tested by

no test coverage detected