MCPcopy Create free account
hub / github.com/cuberite/cuberite / parserCreate

Function parserCreate

lib/expat/xmlparse.c:701–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

699}
700
701static XML_Parser
702parserCreate(const XML_Char *encodingName,
703 const XML_Memory_Handling_Suite *memsuite,
704 const XML_Char *nameSep,
705 DTD *dtd)
706{
707 XML_Parser parser;
708
709 if (memsuite) {
710 XML_Memory_Handling_Suite *mtemp;
711 parser = (XML_Parser)
712 memsuite->malloc_fcn(sizeof(struct XML_ParserStruct));
713 if (parser != NULL) {
714 mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem);
715 mtemp->malloc_fcn = memsuite->malloc_fcn;
716 mtemp->realloc_fcn = memsuite->realloc_fcn;
717 mtemp->free_fcn = memsuite->free_fcn;
718 }
719 }
720 else {
721 XML_Memory_Handling_Suite *mtemp;
722 parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct));
723 if (parser != NULL) {
724 mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem);
725 mtemp->malloc_fcn = malloc;
726 mtemp->realloc_fcn = realloc;
727 mtemp->free_fcn = free;
728 }
729 }
730
731 if (!parser)
732 return parser;
733
734 buffer = NULL;
735 bufferLim = NULL;
736
737 attsSize = INIT_ATTS_SIZE;
738 atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE));
739 if (atts == NULL) {
740 FREE(parser);
741 return NULL;
742 }
743 dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char));
744 if (dataBuf == NULL) {
745 FREE(atts);
746 FREE(parser);
747 return NULL;
748 }
749 dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE;
750
751 if (dtd)
752 _dtd = dtd;
753 else {
754 _dtd = dtdCreate(&parser->m_mem);
755 if (_dtd == NULL) {
756 FREE(dataBuf);
757 FREE(atts);
758 FREE(parser);

Callers 2

XML_ParserCreate_MMFunction · 0.85

Calls 4

dtdCreateFunction · 0.85
poolInitFunction · 0.85
parserInitFunction · 0.85
XML_ParserFreeFunction · 0.85

Tested by

no test coverage detected