* valuePush: * @ctxt: an XPath evaluation context * @value: the XPath object * * Pushes a new XPath object on top of the value stack. If value is NULL, * a memory error is recorded in the parser context. * * Returns the number of items on the value stack, or -1 in case of error. * * The object is destroyed in case of error. */
| 2074 | * The object is destroyed in case of error. |
| 2075 | */ |
| 2076 | int |
| 2077 | valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value) |
| 2078 | { |
| 2079 | if (ctxt == NULL) return(-1); |
| 2080 | if (value == NULL) { |
| 2081 | /* |
| 2082 | * A NULL value typically indicates that a memory allocation failed. |
| 2083 | */ |
| 2084 | xmlXPathPErrMemory(ctxt); |
| 2085 | return(-1); |
| 2086 | } |
| 2087 | if (ctxt->valueNr >= ctxt->valueMax) { |
| 2088 | xmlXPathObjectPtr *tmp; |
| 2089 | |
| 2090 | if (ctxt->valueMax >= XPATH_MAX_STACK_DEPTH) { |
| 2091 | xmlXPathPErrMemory(ctxt); |
| 2092 | xmlXPathFreeObject(value); |
| 2093 | return (-1); |
| 2094 | } |
| 2095 | tmp = (xmlXPathObjectPtr *) xmlRealloc(ctxt->valueTab, |
| 2096 | 2 * ctxt->valueMax * |
| 2097 | sizeof(ctxt->valueTab[0])); |
| 2098 | if (tmp == NULL) { |
| 2099 | xmlXPathPErrMemory(ctxt); |
| 2100 | xmlXPathFreeObject(value); |
| 2101 | return (-1); |
| 2102 | } |
| 2103 | ctxt->valueMax *= 2; |
| 2104 | ctxt->valueTab = tmp; |
| 2105 | } |
| 2106 | ctxt->valueTab[ctxt->valueNr] = value; |
| 2107 | ctxt->value = value; |
| 2108 | return (ctxt->valueNr++); |
| 2109 | } |
| 2110 | |
| 2111 | /** |
| 2112 | * xmlXPathPopBoolean: |
no test coverage detected