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

Function xmlAddDefAttrs

ThirdParty/libxml2/vtklibxml2/parser.c:1058–1168  ·  view source on GitHub ↗

* xmlAddDefAttrs: * @ctxt: an XML parser context * @fullname: the element fullname * @fullattr: the attribute fullname * @value: the attribute value * * Add a defaulted attribute for an element */

Source from the content-addressed store, hash-verified

1056 * Add a defaulted attribute for an element
1057 */
1058static void
1059xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
1060 const xmlChar *fullname,
1061 const xmlChar *fullattr,
1062 const xmlChar *value) {
1063 xmlDefAttrsPtr defaults;
1064 xmlDefAttr *attr;
1065 int len, expandedSize;
1066 xmlHashedString name;
1067 xmlHashedString prefix;
1068 xmlHashedString hvalue;
1069 const xmlChar *localname;
1070
1071 /*
1072 * Allows to detect attribute redefinitions
1073 */
1074 if (ctxt->attsSpecial != NULL) {
1075 if (xmlHashLookup2(ctxt->attsSpecial, fullname, fullattr) != NULL)
1076 return;
1077 }
1078
1079 if (ctxt->attsDefault == NULL) {
1080 ctxt->attsDefault = xmlHashCreateDict(10, ctxt->dict);
1081 if (ctxt->attsDefault == NULL)
1082 goto mem_error;
1083 }
1084
1085 /*
1086 * split the element name into prefix:localname , the string found
1087 * are within the DTD and then not associated to namespace names.
1088 */
1089 localname = xmlSplitQName3(fullname, &len);
1090 if (localname == NULL) {
1091 name = xmlDictLookupHashed(ctxt->dict, fullname, -1);
1092 prefix.name = NULL;
1093 } else {
1094 name = xmlDictLookupHashed(ctxt->dict, localname, -1);
1095 prefix = xmlDictLookupHashed(ctxt->dict, fullname, len);
1096 if (prefix.name == NULL)
1097 goto mem_error;
1098 }
1099 if (name.name == NULL)
1100 goto mem_error;
1101
1102 /*
1103 * make sure there is some storage
1104 */
1105 defaults = xmlHashLookup2(ctxt->attsDefault, name.name, prefix.name);
1106 if ((defaults == NULL) ||
1107 (defaults->nbAttrs >= defaults->maxAttrs)) {
1108 xmlDefAttrsPtr temp;
1109 int newSize;
1110
1111 newSize = (defaults != NULL) ? 2 * defaults->maxAttrs : 4;
1112 temp = xmlRealloc(defaults,
1113 sizeof(*defaults) + newSize * sizeof(xmlDefAttr));
1114 if (temp == NULL)
1115 goto mem_error;

Callers 1

Calls 6

xmlHashLookup2Function · 0.85
xmlHashCreateDictFunction · 0.85
xmlSplitQName3Function · 0.85
xmlDictLookupHashedFunction · 0.85
xmlHashUpdateEntry2Function · 0.85
xmlErrMemoryFunction · 0.85

Tested by

no test coverage detected