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

Function xmlNewText

ThirdParty/libxml2/vtklibxml2/tree.c:2290–2317  ·  view source on GitHub ↗

* xmlNewText: * @content: raw text content (optional) * * Create a text node. * * Use of this function is DISCOURAGED in favor of xmlNewDocText. * * Returns a pointer to the new node object or NULL if a memory * allocation failed. */

Source from the content-addressed store, hash-verified

2288 * allocation failed.
2289 */
2290xmlNodePtr
2291xmlNewText(const xmlChar *content) {
2292 xmlNodePtr cur;
2293
2294 /*
2295 * Allocate a new node and fill the fields.
2296 */
2297 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2298 if (cur == NULL)
2299 return(NULL);
2300 memset(cur, 0, sizeof(xmlNode));
2301 cur->type = XML_TEXT_NODE;
2302
2303 cur->name = xmlStringText;
2304 if (content != NULL) {
2305 cur->content = xmlStrdup(content);
2306 if (cur->content == NULL)
2307 goto error;
2308 }
2309
2310 if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
2311 xmlRegisterNodeDefaultValue(cur);
2312 return(cur);
2313
2314error:
2315 xmlFreeNode(cur);
2316 return(NULL);
2317}
2318
2319#ifdef LIBXML_TREE_ENABLED
2320/**

Callers 3

visitMethod · 0.85
xmlNewDocTextFunction · 0.85

Calls 2

xmlStrdupFunction · 0.85
xmlFreeNodeFunction · 0.85

Tested by

no test coverage detected