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

Function xmlStaticCopyNode

ThirdParty/libxml2/vtklibxml2/tree.c:4195–4379  ·  view source on GitHub ↗

* xmlStaticCopyNode: * @node: source node * @doc: target document * @parent: target parent * @extended: flags * * Copy a node. * * Returns the copy or NULL if a memory allocation failed. */

Source from the content-addressed store, hash-verified

4193 * Returns the copy or NULL if a memory allocation failed.
4194 */
4195xmlNodePtr
4196xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
4197 int extended) {
4198 xmlNodePtr ret;
4199
4200 if (node == NULL) return(NULL);
4201 switch (node->type) {
4202 case XML_TEXT_NODE:
4203 case XML_CDATA_SECTION_NODE:
4204 case XML_ELEMENT_NODE:
4205 case XML_DOCUMENT_FRAG_NODE:
4206 case XML_ENTITY_REF_NODE:
4207 case XML_PI_NODE:
4208 case XML_COMMENT_NODE:
4209 case XML_XINCLUDE_START:
4210 case XML_XINCLUDE_END:
4211 break;
4212 case XML_ATTRIBUTE_NODE:
4213 return((xmlNodePtr) xmlCopyPropInternal(doc, parent, (xmlAttrPtr) node));
4214 case XML_NAMESPACE_DECL:
4215 return((xmlNodePtr) xmlCopyNamespaceList((xmlNsPtr) node));
4216
4217 case XML_DOCUMENT_NODE:
4218 case XML_HTML_DOCUMENT_NODE:
4219#ifdef LIBXML_TREE_ENABLED
4220 return((xmlNodePtr) xmlCopyDoc((xmlDocPtr) node, extended));
4221#endif /* LIBXML_TREE_ENABLED */
4222 default:
4223 return(NULL);
4224 }
4225
4226 /*
4227 * Allocate a new node and fill the fields.
4228 */
4229 ret = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
4230 if (ret == NULL)
4231 return(NULL);
4232 memset(ret, 0, sizeof(xmlNode));
4233 ret->type = node->type;
4234
4235 ret->doc = doc;
4236 ret->parent = parent;
4237 if (node->name == xmlStringText)
4238 ret->name = xmlStringText;
4239 else if (node->name == xmlStringTextNoenc)
4240 ret->name = xmlStringTextNoenc;
4241 else if (node->name == xmlStringComment)
4242 ret->name = xmlStringComment;
4243 else if (node->name != NULL) {
4244 if ((doc != NULL) && (doc->dict != NULL))
4245 ret->name = xmlDictLookup(doc->dict, node->name, -1);
4246 else
4247 ret->name = xmlStrdup(node->name);
4248 if (ret->name == NULL)
4249 goto error;
4250 }
4251 if ((node->type != XML_ELEMENT_NODE) &&
4252 (node->content != NULL) &&

Callers 4

xmlStaticCopyNodeListFunction · 0.85
xmlCopyNodeFunction · 0.85
xmlDocCopyNodeFunction · 0.85
xmlXIncludeCopyNodeFunction · 0.85

Calls 11

xmlCopyPropInternalFunction · 0.85
xmlCopyNamespaceListFunction · 0.85
xmlCopyDocFunction · 0.85
xmlDictLookupFunction · 0.85
xmlStrdupFunction · 0.85
xmlSearchNsSafeFunction · 0.85
xmlNewNsFunction · 0.85
xmlNewReconciledNsFunction · 0.85
xmlCopyPropListFunction · 0.85
xmlGetDocEntityFunction · 0.85
xmlFreeNodeFunction · 0.85

Tested by

no test coverage detected