MCPcopy Create free account
hub / github.com/Kitware/CMake / dtdCopy

Function dtdCopy

Utilities/cmexpat/lib/xmlparse.c:7592–7726  ·  view source on GitHub ↗

Do a deep copy of the DTD. Return 0 for out of memory, non-zero otherwise. The new DTD has already been initialized. */

Source from the content-addressed store, hash-verified

7590 The new DTD has already been initialized.
7591*/
7592static int
7593dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd,
7594 XML_Parser parser) {
7595 HASH_TABLE_ITER iter;
7596
7597 /* Copy the prefix table. */
7598
7599 hashTableIterInit(&iter, &(oldDtd->prefixes));
7600 for (;;) {
7601 const XML_Char *name;
7602 const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter);
7603 if (! oldP)
7604 break;
7605 name = poolCopyString(&(newDtd->pool), oldP->name);
7606 if (! name)
7607 return 0;
7608 if (! lookup(oldParser, &(newDtd->prefixes), name, sizeof(PREFIX)))
7609 return 0;
7610 }
7611
7612 hashTableIterInit(&iter, &(oldDtd->attributeIds));
7613
7614 /* Copy the attribute id table. */
7615
7616 for (;;) {
7617 ATTRIBUTE_ID *newA;
7618 const XML_Char *name;
7619 const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter);
7620
7621 if (! oldA)
7622 break;
7623 /* Remember to allocate the scratch byte before the name. */
7624 if (! poolAppendChar(&(newDtd->pool), XML_T('\0')))
7625 return 0;
7626 name = poolCopyString(&(newDtd->pool), oldA->name);
7627 if (! name)
7628 return 0;
7629 ++name;
7630 newA = (ATTRIBUTE_ID *)lookup(oldParser, &(newDtd->attributeIds), name,
7631 sizeof(ATTRIBUTE_ID));
7632 if (! newA)
7633 return 0;
7634 newA->maybeTokenized = oldA->maybeTokenized;
7635 if (oldA->prefix) {
7636 newA->xmlns = oldA->xmlns;
7637 if (oldA->prefix == &oldDtd->defaultPrefix)
7638 newA->prefix = &newDtd->defaultPrefix;
7639 else
7640 newA->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes),
7641 oldA->prefix->name, 0);
7642 }
7643 }
7644
7645 /* Copy the element type table. */
7646
7647 hashTableIterInit(&iter, &(oldDtd->elementTypes));
7648
7649 for (;;) {

Callers 1

Calls 5

hashTableIterInitFunction · 0.85
hashTableIterNextFunction · 0.85
poolCopyStringFunction · 0.85
copyEntityTableFunction · 0.85
lookupFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…