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

Function xmlCopyElement

ThirdParty/libxml2/vtklibxml2/valid.c:1365–1398  ·  view source on GitHub ↗

* xmlCopyElement: * @elem: An element * * Build a copy of an element. * * Returns the new xmlElementPtr or NULL in case of error. */

Source from the content-addressed store, hash-verified

1363 * Returns the new xmlElementPtr or NULL in case of error.
1364 */
1365static void *
1366xmlCopyElement(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
1367 xmlElementPtr elem = (xmlElementPtr) payload;
1368 xmlElementPtr cur;
1369
1370 cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
1371 if (cur == NULL)
1372 return(NULL);
1373 memset(cur, 0, sizeof(xmlElement));
1374 cur->type = XML_ELEMENT_DECL;
1375 cur->etype = elem->etype;
1376 if (elem->name != NULL) {
1377 cur->name = xmlStrdup(elem->name);
1378 if (cur->name == NULL)
1379 goto error;
1380 }
1381 if (elem->prefix != NULL) {
1382 cur->prefix = xmlStrdup(elem->prefix);
1383 if (cur->prefix == NULL)
1384 goto error;
1385 }
1386 if (elem->content != NULL) {
1387 cur->content = xmlCopyElementContent(elem->content);
1388 if (cur->content == NULL)
1389 goto error;
1390 }
1391 /* TODO : rebuild the attribute list on the copy */
1392 cur->attributes = NULL;
1393 return(cur);
1394
1395error:
1396 xmlFreeElement(cur);
1397 return(NULL);
1398}
1399
1400/**
1401 * xmlCopyElementTable:

Callers

nothing calls this directly

Calls 3

xmlStrdupFunction · 0.85
xmlCopyElementContentFunction · 0.85
xmlFreeElementFunction · 0.85

Tested by

no test coverage detected