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

Function xmlCopyDocElementContent

ThirdParty/libxml2/vtklibxml2/valid.c:808–891  ·  view source on GitHub ↗

* xmlCopyDocElementContent: * @doc: the document owning the element declaration * @cur: An element content pointer. * * Build a copy of an element content description. * * Returns the new xmlElementContentPtr or NULL in case of error. */

Source from the content-addressed store, hash-verified

806 * Returns the new xmlElementContentPtr or NULL in case of error.
807 */
808xmlElementContentPtr
809xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) {
810 xmlElementContentPtr ret = NULL, prev = NULL, tmp;
811 xmlDictPtr dict = NULL;
812
813 if (cur == NULL) return(NULL);
814
815 if (doc != NULL)
816 dict = doc->dict;
817
818 ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
819 if (ret == NULL)
820 return(NULL);
821 memset(ret, 0, sizeof(xmlElementContent));
822 ret->type = cur->type;
823 ret->ocur = cur->ocur;
824 if (cur->name != NULL) {
825 if (dict)
826 ret->name = xmlDictLookup(dict, cur->name, -1);
827 else
828 ret->name = xmlStrdup(cur->name);
829 if (ret->name == NULL)
830 goto error;
831 }
832
833 if (cur->prefix != NULL) {
834 if (dict)
835 ret->prefix = xmlDictLookup(dict, cur->prefix, -1);
836 else
837 ret->prefix = xmlStrdup(cur->prefix);
838 if (ret->prefix == NULL)
839 goto error;
840 }
841 if (cur->c1 != NULL) {
842 ret->c1 = xmlCopyDocElementContent(doc, cur->c1);
843 if (ret->c1 == NULL)
844 goto error;
845 ret->c1->parent = ret;
846 }
847 if (cur->c2 != NULL) {
848 prev = ret;
849 cur = cur->c2;
850 while (cur != NULL) {
851 tmp = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
852 if (tmp == NULL)
853 goto error;
854 memset(tmp, 0, sizeof(xmlElementContent));
855 tmp->type = cur->type;
856 tmp->ocur = cur->ocur;
857 prev->c2 = tmp;
858 tmp->parent = prev;
859 if (cur->name != NULL) {
860 if (dict)
861 tmp->name = xmlDictLookup(dict, cur->name, -1);
862 else
863 tmp->name = xmlStrdup(cur->name);
864 if (tmp->name == NULL)
865 goto error;

Callers 2

xmlCopyElementContentFunction · 0.85
xmlAddElementDeclFunction · 0.85

Calls 3

xmlDictLookupFunction · 0.85
xmlStrdupFunction · 0.85
xmlFreeElementContentFunction · 0.85

Tested by

no test coverage detected