* 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. */
| 2288 | * allocation failed. |
| 2289 | */ |
| 2290 | xmlNodePtr |
| 2291 | xmlNewText(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 | |
| 2314 | error: |
| 2315 | xmlFreeNode(cur); |
| 2316 | return(NULL); |
| 2317 | } |
| 2318 | |
| 2319 | #ifdef LIBXML_TREE_ENABLED |
| 2320 | /** |
no test coverage detected