* xmlCreateEntity: * * internal routine doing the entity node structures allocations */
| 112 | * internal routine doing the entity node structures allocations |
| 113 | */ |
| 114 | static xmlEntityPtr |
| 115 | xmlCreateEntity(xmlDocPtr doc, const xmlChar *name, int type, |
| 116 | const xmlChar *ExternalID, const xmlChar *SystemID, |
| 117 | const xmlChar *content) { |
| 118 | xmlEntityPtr ret; |
| 119 | |
| 120 | ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity)); |
| 121 | if (ret == NULL) |
| 122 | return(NULL); |
| 123 | memset(ret, 0, sizeof(xmlEntity)); |
| 124 | ret->doc = doc; |
| 125 | ret->type = XML_ENTITY_DECL; |
| 126 | |
| 127 | /* |
| 128 | * fill the structure. |
| 129 | */ |
| 130 | ret->etype = (xmlEntityType) type; |
| 131 | if ((doc == NULL) || (doc->dict == NULL)) |
| 132 | ret->name = xmlStrdup(name); |
| 133 | else |
| 134 | ret->name = xmlDictLookup(doc->dict, name, -1); |
| 135 | if (ret->name == NULL) |
| 136 | goto error; |
| 137 | if (ExternalID != NULL) { |
| 138 | ret->ExternalID = xmlStrdup(ExternalID); |
| 139 | if (ret->ExternalID == NULL) |
| 140 | goto error; |
| 141 | } |
| 142 | if (SystemID != NULL) { |
| 143 | ret->SystemID = xmlStrdup(SystemID); |
| 144 | if (ret->SystemID == NULL) |
| 145 | goto error; |
| 146 | } |
| 147 | if (content != NULL) { |
| 148 | ret->length = xmlStrlen(content); |
| 149 | ret->content = xmlStrndup(content, ret->length); |
| 150 | if (ret->content == NULL) |
| 151 | goto error; |
| 152 | } else { |
| 153 | ret->length = 0; |
| 154 | ret->content = NULL; |
| 155 | } |
| 156 | ret->URI = NULL; /* to be computed by the layer knowing |
| 157 | the defining entity */ |
| 158 | ret->orig = NULL; |
| 159 | |
| 160 | return(ret); |
| 161 | |
| 162 | error: |
| 163 | xmlFreeEntity(ret); |
| 164 | return(NULL); |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * xmlAddEntity: |
no test coverage detected