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

Function xmlNewDocPI

ThirdParty/libxml2/vtklibxml2/tree.c:1993–2030  ·  view source on GitHub ↗

* xmlNewDocPI: * @doc: the target document (optional) * @name: the processing instruction target * @content: the PI content (optional) * * Create a processing instruction object. * * Returns a pointer to the new node object or NULL if arguments are * invalid or a memory allocation failed. */

Source from the content-addressed store, hash-verified

1991 * invalid or a memory allocation failed.
1992 */
1993xmlNodePtr
1994xmlNewDocPI(xmlDocPtr doc, const xmlChar *name, const xmlChar *content) {
1995 xmlNodePtr cur;
1996
1997 if (name == NULL) {
1998 return(NULL);
1999 }
2000
2001 /*
2002 * Allocate a new node and fill the fields.
2003 */
2004 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2005 if (cur == NULL)
2006 return(NULL);
2007 memset(cur, 0, sizeof(xmlNode));
2008 cur->type = XML_PI_NODE;
2009 cur->doc = doc;
2010
2011 if ((doc != NULL) && (doc->dict != NULL))
2012 cur->name = xmlDictLookup(doc->dict, name, -1);
2013 else
2014 cur->name = xmlStrdup(name);
2015 if (cur->name == NULL)
2016 goto error;
2017 if (content != NULL) {
2018 cur->content = xmlStrdup(content);
2019 if (cur->content == NULL)
2020 goto error;
2021 }
2022
2023 if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
2024 xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
2025 return(cur);
2026
2027error:
2028 xmlFreeNode(cur);
2029 return(NULL);
2030}
2031
2032/**
2033 * xmlNewPI:

Callers 2

xmlNewPIFunction · 0.85

Calls 3

xmlDictLookupFunction · 0.85
xmlStrdupFunction · 0.85
xmlFreeNodeFunction · 0.85

Tested by

no test coverage detected