* nodePush: * @ctxt: an XML parser context * @value: the element node * * DEPRECATED: Internal function, do not use. * * Pushes a new element node on top of the node stack * * Returns -1 in case of error, the index in the stack otherwise */
| 2015 | * Returns -1 in case of error, the index in the stack otherwise |
| 2016 | */ |
| 2017 | int |
| 2018 | nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value) |
| 2019 | { |
| 2020 | int maxDepth; |
| 2021 | |
| 2022 | if (ctxt == NULL) |
| 2023 | return(0); |
| 2024 | |
| 2025 | maxDepth = (ctxt->options & XML_PARSE_HUGE) ? 2048 : 256; |
| 2026 | if (ctxt->nodeNr > maxDepth) { |
| 2027 | xmlFatalErrMsgInt(ctxt, XML_ERR_RESOURCE_LIMIT, |
| 2028 | "Excessive depth in document: %d use XML_PARSE_HUGE option\n", |
| 2029 | ctxt->nodeNr); |
| 2030 | xmlHaltParser(ctxt); |
| 2031 | return(-1); |
| 2032 | } |
| 2033 | if (ctxt->nodeNr >= ctxt->nodeMax) { |
| 2034 | xmlNodePtr *tmp; |
| 2035 | |
| 2036 | tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab, |
| 2037 | ctxt->nodeMax * 2 * |
| 2038 | sizeof(ctxt->nodeTab[0])); |
| 2039 | if (tmp == NULL) { |
| 2040 | xmlErrMemory(ctxt); |
| 2041 | return (-1); |
| 2042 | } |
| 2043 | ctxt->nodeTab = tmp; |
| 2044 | ctxt->nodeMax *= 2; |
| 2045 | } |
| 2046 | ctxt->nodeTab[ctxt->nodeNr] = value; |
| 2047 | ctxt->node = value; |
| 2048 | return (ctxt->nodeNr++); |
| 2049 | } |
| 2050 | |
| 2051 | /** |
| 2052 | * nodePop: |
no test coverage detected