* inputPush: * @ctxt: an XML parser context * @value: the parser input * * Pushes a new parser input on top of the input stack * * Returns -1 in case of error, the index in the stack otherwise */
| 1938 | * Returns -1 in case of error, the index in the stack otherwise |
| 1939 | */ |
| 1940 | int |
| 1941 | inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value) |
| 1942 | { |
| 1943 | char *directory = NULL; |
| 1944 | |
| 1945 | if ((ctxt == NULL) || (value == NULL)) |
| 1946 | return(-1); |
| 1947 | |
| 1948 | if (ctxt->inputNr >= ctxt->inputMax) { |
| 1949 | size_t newSize = ctxt->inputMax * 2; |
| 1950 | xmlParserInputPtr *tmp; |
| 1951 | |
| 1952 | tmp = (xmlParserInputPtr *) xmlRealloc(ctxt->inputTab, |
| 1953 | newSize * sizeof(*tmp)); |
| 1954 | if (tmp == NULL) { |
| 1955 | xmlErrMemory(ctxt); |
| 1956 | return (-1); |
| 1957 | } |
| 1958 | ctxt->inputTab = tmp; |
| 1959 | ctxt->inputMax = newSize; |
| 1960 | } |
| 1961 | |
| 1962 | if ((ctxt->inputNr == 0) && (value->filename != NULL)) { |
| 1963 | directory = xmlParserGetDirectory(value->filename); |
| 1964 | if (directory == NULL) { |
| 1965 | xmlErrMemory(ctxt); |
| 1966 | return(-1); |
| 1967 | } |
| 1968 | } |
| 1969 | |
| 1970 | ctxt->inputTab[ctxt->inputNr] = value; |
| 1971 | ctxt->input = value; |
| 1972 | |
| 1973 | if (ctxt->inputNr == 0) { |
| 1974 | xmlFree(ctxt->directory); |
| 1975 | ctxt->directory = directory; |
| 1976 | } |
| 1977 | |
| 1978 | return(ctxt->inputNr++); |
| 1979 | } |
| 1980 | /** |
| 1981 | * inputPop: |
| 1982 | * @ctxt: an XML parser context |
no test coverage detected