* xmlNewDoc: * @version: XML version string like "1.0" (optional) * * Creates a new XML document. If version is NULL, "1.0" is used. * * Returns a new document or NULL if a memory allocation failed. */
| 1090 | * Returns a new document or NULL if a memory allocation failed. |
| 1091 | */ |
| 1092 | xmlDocPtr |
| 1093 | xmlNewDoc(const xmlChar *version) { |
| 1094 | xmlDocPtr cur; |
| 1095 | |
| 1096 | if (version == NULL) |
| 1097 | version = (const xmlChar *) "1.0"; |
| 1098 | |
| 1099 | /* |
| 1100 | * Allocate a new document and fill the fields. |
| 1101 | */ |
| 1102 | cur = (xmlDocPtr) xmlMalloc(sizeof(xmlDoc)); |
| 1103 | if (cur == NULL) |
| 1104 | return(NULL); |
| 1105 | memset(cur, 0, sizeof(xmlDoc)); |
| 1106 | cur->type = XML_DOCUMENT_NODE; |
| 1107 | |
| 1108 | cur->version = xmlStrdup(version); |
| 1109 | if (cur->version == NULL) { |
| 1110 | xmlFree(cur); |
| 1111 | return(NULL); |
| 1112 | } |
| 1113 | cur->standalone = -1; |
| 1114 | cur->compression = -1; /* not initialized */ |
| 1115 | cur->doc = cur; |
| 1116 | cur->parseFlags = 0; |
| 1117 | cur->properties = XML_DOC_USERBUILT; |
| 1118 | /* |
| 1119 | * The in memory encoding is always UTF8 |
| 1120 | * This field will never change and would |
| 1121 | * be obsolete if not for binary compatibility. |
| 1122 | */ |
| 1123 | cur->charset = XML_CHAR_ENCODING_UTF8; |
| 1124 | |
| 1125 | if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) |
| 1126 | xmlRegisterNodeDefaultValue((xmlNodePtr)cur); |
| 1127 | return(cur); |
| 1128 | } |
| 1129 | |
| 1130 | /** |
| 1131 | * xmlFreeDoc: |
no test coverage detected