* xmlCopyElement: * @elem: An element * * Build a copy of an element. * * Returns the new xmlElementPtr or NULL in case of error. */
| 1363 | * Returns the new xmlElementPtr or NULL in case of error. |
| 1364 | */ |
| 1365 | static void * |
| 1366 | xmlCopyElement(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 | |
| 1395 | error: |
| 1396 | xmlFreeElement(cur); |
| 1397 | return(NULL); |
| 1398 | } |
| 1399 | |
| 1400 | /** |
| 1401 | * xmlCopyElementTable: |
nothing calls this directly
no test coverage detected