* nameNsPush: * @ctxt: an XML parser context * @value: the element name * @prefix: the element prefix * @URI: the element namespace name * @line: the current line number for error messages * @nsNr: the number of namespaces pushed on the namespace table * * Pushes a new element name/prefix/URL on top of the name stack * * Returns -1 in case of error, the index in the stack otherwise
| 2090 | * Returns -1 in case of error, the index in the stack otherwise |
| 2091 | */ |
| 2092 | static int |
| 2093 | nameNsPush(xmlParserCtxtPtr ctxt, const xmlChar * value, |
| 2094 | const xmlChar *prefix, const xmlChar *URI, int line, int nsNr) |
| 2095 | { |
| 2096 | xmlStartTag *tag; |
| 2097 | |
| 2098 | if (ctxt->nameNr >= ctxt->nameMax) { |
| 2099 | const xmlChar * *tmp; |
| 2100 | xmlStartTag *tmp2; |
| 2101 | ctxt->nameMax *= 2; |
| 2102 | tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab, |
| 2103 | ctxt->nameMax * |
| 2104 | sizeof(ctxt->nameTab[0])); |
| 2105 | if (tmp == NULL) { |
| 2106 | ctxt->nameMax /= 2; |
| 2107 | goto mem_error; |
| 2108 | } |
| 2109 | ctxt->nameTab = tmp; |
| 2110 | tmp2 = (xmlStartTag *) xmlRealloc((void * *)ctxt->pushTab, |
| 2111 | ctxt->nameMax * |
| 2112 | sizeof(ctxt->pushTab[0])); |
| 2113 | if (tmp2 == NULL) { |
| 2114 | ctxt->nameMax /= 2; |
| 2115 | goto mem_error; |
| 2116 | } |
| 2117 | ctxt->pushTab = tmp2; |
| 2118 | } else if (ctxt->pushTab == NULL) { |
| 2119 | ctxt->pushTab = (xmlStartTag *) xmlMalloc(ctxt->nameMax * |
| 2120 | sizeof(ctxt->pushTab[0])); |
| 2121 | if (ctxt->pushTab == NULL) |
| 2122 | goto mem_error; |
| 2123 | } |
| 2124 | ctxt->nameTab[ctxt->nameNr] = value; |
| 2125 | ctxt->name = value; |
| 2126 | tag = &ctxt->pushTab[ctxt->nameNr]; |
| 2127 | tag->prefix = prefix; |
| 2128 | tag->URI = URI; |
| 2129 | tag->line = line; |
| 2130 | tag->nsNr = nsNr; |
| 2131 | return (ctxt->nameNr++); |
| 2132 | mem_error: |
| 2133 | xmlErrMemory(ctxt); |
| 2134 | return (-1); |
| 2135 | } |
| 2136 | #ifdef LIBXML_PUSH_ENABLED |
| 2137 | /** |
| 2138 | * nameNsPop: |
no test coverage detected