* xmlNewTextLen: * @content: raw text content (optional) * @len: size of text content * * Use of this function is DISCOURAGED in favor of xmlNewDocTextLen. * * Returns a pointer to the new node object or NULL if a memory * allocation failed. */
| 2550 | * allocation failed. |
| 2551 | */ |
| 2552 | xmlNodePtr |
| 2553 | xmlNewTextLen(const xmlChar *content, int len) { |
| 2554 | xmlNodePtr cur; |
| 2555 | |
| 2556 | /* |
| 2557 | * Allocate a new node and fill the fields. |
| 2558 | */ |
| 2559 | cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); |
| 2560 | if (cur == NULL) |
| 2561 | return(NULL); |
| 2562 | memset(cur, 0, sizeof(xmlNode)); |
| 2563 | cur->type = XML_TEXT_NODE; |
| 2564 | |
| 2565 | cur->name = xmlStringText; |
| 2566 | if (content != NULL) { |
| 2567 | cur->content = xmlStrndup(content, len); |
| 2568 | if (cur->content == NULL) { |
| 2569 | xmlFreeNode(cur); |
| 2570 | return(NULL); |
| 2571 | } |
| 2572 | } |
| 2573 | |
| 2574 | if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) |
| 2575 | xmlRegisterNodeDefaultValue(cur); |
| 2576 | return(cur); |
| 2577 | } |
| 2578 | |
| 2579 | /** |
| 2580 | * xmlNewDocTextLen: |
no test coverage detected