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

Function xmlInitSAXParserCtxt

ThirdParty/libxml2/vtklibxml2/parserInternals.c:2288–2440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2286 */
2287
2288static int
2289xmlInitSAXParserCtxt(xmlParserCtxtPtr ctxt, const xmlSAXHandler *sax,
2290 void *userData)
2291{
2292 xmlParserInputPtr input;
2293
2294 if (ctxt == NULL)
2295 return(-1);
2296
2297 if (ctxt->dict == NULL)
2298 ctxt->dict = xmlDictCreate();
2299 if (ctxt->dict == NULL)
2300 return(-1);
2301 xmlDictSetLimit(ctxt->dict, XML_MAX_DICTIONARY_LIMIT);
2302
2303 if (ctxt->sax == NULL)
2304 ctxt->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
2305 if (ctxt->sax == NULL)
2306 return(-1);
2307 if (sax == NULL) {
2308 memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
2309 xmlSAXVersion(ctxt->sax, 2);
2310 ctxt->userData = ctxt;
2311 } else {
2312 if (sax->initialized == XML_SAX2_MAGIC) {
2313 memcpy(ctxt->sax, sax, sizeof(xmlSAXHandler));
2314 } else {
2315 memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
2316 memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
2317 }
2318 ctxt->userData = userData ? userData : ctxt;
2319 }
2320
2321 ctxt->maxatts = 0;
2322 ctxt->atts = NULL;
2323 /* Allocate the Input stack */
2324 if (ctxt->inputTab == NULL) {
2325 ctxt->inputTab = (xmlParserInputPtr *)
2326 xmlMalloc(5 * sizeof(xmlParserInputPtr));
2327 ctxt->inputMax = 5;
2328 }
2329 if (ctxt->inputTab == NULL)
2330 return(-1);
2331 while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
2332 xmlFreeInputStream(input);
2333 }
2334 ctxt->inputNr = 0;
2335 ctxt->input = NULL;
2336
2337 ctxt->version = NULL;
2338 ctxt->encoding = NULL;
2339 ctxt->standalone = -1;
2340 ctxt->hasExternalSubset = 0;
2341 ctxt->hasPErefs = 0;
2342 ctxt->html = 0;
2343 ctxt->instate = XML_PARSER_START;
2344
2345 /* Allocate the Node stack */

Callers 2

xmlInitParserCtxtFunction · 0.85
xmlNewSAXParserCtxtFunction · 0.85

Calls 8

xmlDictCreateFunction · 0.85
xmlDictSetLimitFunction · 0.85
xmlSAXVersionFunction · 0.85
inputPopFunction · 0.85
xmlFreeInputStreamFunction · 0.85
xmlInitNodeInfoSeqFunction · 0.85
xmlParserNsCreateFunction · 0.85
xmlCtxtErrMemoryFunction · 0.85

Tested by

no test coverage detected